一尘不染

GOPATH和GOROOT的值应该是多少?

go

我正在尝试像这样安装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

阅读 260

收藏
2020-07-02

共1个答案

一尘不染

GOPATHcmd/go文档中进行了讨论:

GOPATH环境变量列表地方寻找Go代码。在Unix上,该值是用冒号分隔的字符串。在Windows上,该值为分号分隔的字符串。在计划9中,该值是一个列表。

GOPATH 必须设置为获取,构建和安装标准Go树之外的软件包。

GOROOT安装说明中讨论:

Go二进制发行版假定它们将安装在/usr/local/go(或c:\GoWindows下),但是可以将Go工具安装到其他位置。在这种情况下,您必须将GOROOT环境变量设置
为指向其安装目录。

例如,如果您安装了转到主目录,则应将以下命令添加到$HOME/.profile

export GOROOT=$HOME/go
export PATH=$PATH:$GOROOT/bin

注意: GOROOT仅在安装到自定义位置时才必须设置。

2020-07-02