Getting GOPATH error "go: cannot use path@version syntax in GOPATH mode" in Ubuntu 16.04
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
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]
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
.