Search code examples
gogopath

Getting GOPATH error "go: cannot use path@version syntax in GOPATH mode" in Ubuntu 16.04


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

Solution

  • 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.