我试图像这样安装doozer:

$ goinstall github.com/ha/doozer

我得到这些错误。

goinstall: os: go/build: package could not be found locally goinstall: fmt: go/build: package could not be found locally goinstall: io: go/build: package could not be found locally goinstall: reflect: go/build: package could not be found locally goinstall: math: go/build: package could not be found locally goinstall: rand: go/build: package could not be found locally goinstall: url: go/build: package could not be found locally goinstall: net: go/build: package could not be found locally goinstall: sync: go/build: package could not be found locally goinstall: runtime: go/build: package could not be found locally goinstall: strings: go/build: package could not be found locally goinstall: sort: go/build: package could not be found locally goinstall: strconv: go/build: package could not be found locally goinstall: bytes: go/build: package could not be found locally goinstall: log: go/build: package could not be found locally goinstall: encoding/binary: go/build: package could not be found locally


当前回答

在osx中,我安装了brew,下面是适合我的设置

GOPATH="$HOME/my_go_work_space" //make sure you have this folder created

GOROOT="/usr/local/Cellar/go/1.10/libexec"

其他回答

如果你正在使用发行版go,你应该指向包含文件的位置,例如:

$ rpm -ql golang | grep include
/usr/lib/golang/include

(这是针对Fedora 20)

你可以使用一个命令:go env GOPATH

截至2020年和Go版本1.13+,在Windows中更新GOPATH的最佳方法是在命令提示符中输入:

setx GOPATH C:\mynewgopath

安装Go lang之后,GOROOT是安装的根目录。

当我在Windows C:\目录中分解Go Lang二进制时,我的GOROOT应该是C:\ Go。 如果安装Windows安装程序,它可能是C:\Program Files\go(或C:\Program Files (x86)\ go, 64位包)

 GOROOT = C:\go

而我的GOPATH是Go lang源代码或工作区的位置。

如果我的Go lang源代码位于C:\Users\\GO_Workspace,那么你的GOPATH将如下所示:

 GOPATH = C:\Users\<xyz>\GO_Workspace

对于所有新手,如果你正在使用Ubuntu,他们可以简单地导出GOPATH=$HOME/go,或者去帮助GOPATH获取更多信息。