I'm install the go with the go1.3.1.windows-amd64.msi, after installation GOROOT is default setting, I found the
D:\Programs\Go\bin in the PATH,then I create a GOPATH environment variant,
when using the 'go get' command, error occurs:
package github.com/coreos/etcd: cannot download, $GOPATH must not be set to $GOROOT. For more details see: go help gopath
OS: windows 7
GOPATH will conflict with GOROOT?
How can I set these two PATH values?
Best Answer
GOROOT
must reference the folder where you installed GOGOPATH
must reference an empty folder which will be your workspace (src/pkg/bin for your projects)Add those two variables in your user environment variables.
A
go get github.com/coreos/etcd
should:%GOPATH%/src/github.com/coreos/etcd
(src
is created for you)%GOPATH%/pkg/windows_amd64
(pkg/
is created for you,windows_amd64
reflects your windows architecture)go install
, install it in%GOPATH%/bin
(bin/
is also created for you)Note: with Go 1.8+ (Q2 2017),
GOPATH
might be set for you by default to (on Windows)%USERPROFILE%/go
.On Linux, it would be
$HOME/go
: see issue 17262.Update 2018, three years later:
GOPATH
is becoming obsolete with Go 1.11 modules: