I'm unable to run go get git@github<user/repo>
in my $GOPATH
folder.
Getting this error:
go: cannot use path@version syntax in GOPATH mode
I just want to understand why go get
isn't working even though $GOPATH
is configured during the installation. Environment is ubuntu.
~/$ echo $GOPATH
/home/user/go
I had the same issue and solved setting specific env variable export GO111MODULE=on
in my .zshrc(or .bashrc depending on which shell you use) and restart the shell in order to enable modules. You can find more details here: https://github.com/golang/go/wiki/Modules
As you already noticed, you should use go get github.com/<user>/<repo>
.
The error message you saw comes from a new feature implemented in go get
to support Go modules - you can now also specify the version of a dependency: go get github.com/<user>/<repo>@<version>
, where version
is a git tag using semver, e.g. v1.0.2
.
I met this issue, too. After some search, the following works by using go mod
instead of go get
, which is a feature of Golang Modules:
$ export GO111MODULE=on
$ go mod init <project name>
# go mod init HelloWorld
# or
# go mod init .
$ go mod download repo@version
# go mod download github.com/robfig/cron/[email protected]
I got this error with Go v1.14 when running $ go get github.com/<user>/<repo>@<version>
on an empty project before I had initialized my project with modules.
To resolve, I created a go.mod
file using:
$ go mod init
I was able to rerun the get command successfully, which downloaded the vendor's package, updated the go.mod
file, and created a go.sum
file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With