How can I go get this kubernetes package.
I have tried the following
go get k8s.io/kubernetes/pkg/serviceaccount
but I get the error
go: k8s.io/api#v0.0.0: reading k8s.io/api/go.mod at revision v0.0.0: unknown revision v0.0.0
any suggestions on how I get it ?
It looks like the kubernetes version which you are trying is not available. Please update your go.mod file to use an updated version.
Require { k8s.io/api v0.22.1} and try running ‘go get k8s.io/kubernetes/pkg/serviceaccount’ again. Please check this official page, and also check this comment.
Related
when I execute below cmd:
go get k8s.io/client-go#v12.0.0
it tells me: "go: k8s.io/client-go#v12.0.0: invalid version: module contains a go.mod file, so module path must match major version ("k8s.io/client-go/v12")"
ok, then I changed the cmd to this:
go get k8s.io/client-go#v12.0.0+incompatible
then again, it still tells me the same error: go: k8s.io/client-go#v12.0.0+incompatible: invalid version: module contains a go.mod file, so module path must match major version ("k8s.io/client-go/v12")
one interesting thing puzzles me that if I add require k8s.io/client-go v12.0.0+incompatible to go.mod and then execute go mod tidy, then client-go v12.0.0 will be downloaded correctly.
My question is: how can I download this specific version of client-go via go get??
Go Version: v1.18
I used the go install command to download client-go
Here are two examples to install the latest or specific version.
go install k8s.io/client-go#latest
go install k8s.io/client-go#v0.25.3
See client-go installation section for more help,
client-go install
how can I download this specific version of client-go via go get
Not at all.
go get is for adding dependencies to your project.
To download source code in a certain version from the internet use git clone and git checkout.
Hi guys does anyone would know what is the issue with this package:
go: loading module retractions for github.com/googleapis/gax-go/v2#v2.0.1: parsing go.mod: go.mod:8:2: require google.golang.org/genproto: version "b98a9ff5e252" invalid: must be of the form v1.2.3
after doing go get -u ./... or how to work around to fix this ?
The go.mod file of the module you are trying to import is broken. As the message you posted says, the version number should start with "v" (see here)
It seems that the module was broken by a bot https://github.com/googleapis/gax-go/commit/735836c34b8124d657958d469998865569e14742
The solution would be to revert the commit on the googleapis/gax-go repository.
I want to use latest prometheus in my project. The latest code in github.com/prometheus/prometheus is at version v2.34.0
when i do go get github.com/prometheus/prometheus in my module, i get this line added to my go.mod
require github.com/prometheus/prometheus v2.5.0+incompatible // indirect
but this is not the one i want. i want latest code as in the repo.
i checked https://pkg.go.dev/github.com/prometheus/prometheus , there it shows the version is v2.5.0+incompatible, and was published on Nov 6, 2018
Does go get <module> always look in pkg.go.dev or is pkg.go.dev facing same issue as i am facing?
i tried going to GOMODCACHE and deleting the module version v2.5.0+incompatible and trying go get github.com/prometheus/prometheus#latest but it again pulls same version.
How do i get the latest source of prometheus in my mod cache?
Edit:
I was suggested to run go get github.com/prometheus/prometheus#v2.34.0, this is what i get
$ go get github.com/prometheus/prometheus#v2.34.0
go: github.com/prometheus/prometheus#v2.34.0: invalid version: module contains a go.mod file, so module path must match major version ("github.com/prometheus/prometheus/v2")
I'm trying to make available a cli tool written in Go but I'm getting the following error when trying to install it using:
go install github.com/myuser/mytool#latest
The error:
go install: github.com/myuser/mytool#latest: module github.com/myuser/mytool#latest found (v0.0.1), but does not contain package github.com/myuser/mytool
I have created a v0.0.1 tag and added the binaries for release.
Also tried:
go get -u github.com/myuser/mytool
Then I get no output and the binary is not installed.
More Info:
go.mod:
module github.com/myuser/mytool
go 1.17
require github.com/fatih/color v1.13.0
require (
github.com/mattn/go-colorable v0.1.11 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
golang.org/x/sys v0.0.0-20211117180635-dee7805ff2e1 // indirect
)
Go version:
go version go1.17.2 darwin/arm64
Obs: I can install any other tool on github in the same way as the above.
EDIT
Someone has voted to close the issue for lack of clarity. Would help if you could also be more clear and say what do you think I'm missing here.
My assumption would be that you didn't publish this as a package. check out this link for information on modules and publishing.
I have a shell script setup for one of my projects to upload it as a package, shown below:
!/bin/bash
git tag $1
git push origin $1
GOPROXY=proxy.golang.org go list -m github.com/myuser/mytool#$1
$1 refers to the first parameter of the script, which is the version number.
What version of Go are you using (go version)?
$ go version
v1.12
The module yiigo has tag v3.0.0, but when I run go get github.com/iiinsomnia/yiigo, it gets the v2.1.0 and when I run go get github.com/iiinsomnia/yiigo#v3.0.0, it shows: go get github.com/iiinsomnia/yiigo#v3.0.0: unexpected end of JSON input
The primary issue seems to be that the v3.0.0 version of iiinsomnia/yiigo is missing the required /v3 at the end of the module line in its go.mod file:
https://github.com/iiinsomnia/yiigo/blob/v3.0.0/go.mod#L1
module github.com/iiinsomnia/yiigo <<<< wrong, missing required /v3 at end
go 1.12
require (
github.com/go-sql-driver/mysql v1.4.1-0.20190217072658-972a708cf979
...
That has since been corrected.
Because it is now a proper v3 module, the go get command should include a /v3 before the #:
module github.com/iiinsomnia/yiigo/v3#v3.2.2
From the Go modules wiki:
If the module is version v2 or higher, the major version of the module must be included as a /vN at the end of the module paths used in go.mod files (e.g., module github.com/my/mod/v2, require github.com/my/mod/v2 v2.0.0) and in the package import path (e.g., import "github.com/my/mod/v2/mypkg").
Also, it looks like a related issue was opened, with the theory being that the odd "unexpected end of JSON input" error might have come from some proxy:
https://github.com/golang/go/issues/30494
A way I've accomplished this in the past is by using git tags- for your case this should work fine.
Steps:
go get -u github.com/iiinsomnia/yiigo
cd ~/go/src/github.com/iiinsomnia/yiigo
git tag
locate tag release version you'd like to install within list
git checkout v3.0.0
go install
This will overwrite the package previously installed in your GOPATH with a new one for the specific tag version you have checked out.
Note: there is likely a better way to do this since the release of go modules.
This related post also provides alternative solutions on how to retrieve a specific version of a project's source code that may lend some help.