Ubuntu 16.04出现GOPATH错误:“开始:无法在GOPATH模式下使用path@version语法”

我在我的 $GOPATH 里跑不动了 go get git@github<user/repo>
一直报错:
go: cannot use path@version syntax in GOPATH mode
即使在安装过程中配置好$GOPATH为什么 go get 也不起作用?

~/$ echo $GOPATH
/home/user/go

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 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 go 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/v3@v3.0.0