我试图像这样安装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


当前回答

值应该是(MACOS):

GOROOT="/usr/local/go" --> all binaries file core go
GOPATH="/Applications/proyectos/go" --> the route to workspace (custom workspace)

其他回答

如上所述:

GOPATH环境变量指定您的 工作区。

对于Windows,这对我来说是有效的(在Ms-dos窗口中):

set GOPATH=D:\my_folder_for_go_code\

这将创建一个Ms-dos识别的GOPATH变量,使用如下:

cd %GOPATH%

我读了go help gopath文档,仍然非常困惑,但从另一个go文档页面中发现了这个小块:

GOPATH环境变量指定工作空间的位置。它可能是开发Go代码时需要设置的唯一环境变量。

http://golang.org/doc/code.html#GOPATH

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

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

(这是针对Fedora 20)

不建议使用GOPATH和GOROOT配置。

您可以使用GO模块。

例如:

mkdir go_app
cd go_app
go mod init go_app

值应该是(MACOS):

GOROOT="/usr/local/go" --> all binaries file core go
GOPATH="/Applications/proyectos/go" --> the route to workspace (custom workspace)