GOPATH和GOROOT的价值应该是什么? [英] what should be the values of GOPATH and GOROOT?
问题描述
$ goinstall github.com/ha/doozer
我收到这些错误。
$ b $ pre $
goinstall:os:go / build:在本地找不到包
goinstall:fmt:go / build:在本地找不到包
goinstall:io:go / build:在本地找不到包
goinstall:reflect:go / build:在本地找不到包
goinstall:math: go / build:在本地找不到包
goinstall:rand:go / build:在本地找不到包
goinstall:url:go / build:在本地找不到包
goinstall:net:go / build:在本地找不到包
goinstall:sync:go / build:在本地找不到包
goinstall:runtime:go / build:在本地找不到包
goinstall:strings:go / build:在本地找不到包
goinstall:sort:go / build:在本地找不到包$ b $ goinstall:strconv:go / build:package可能不在本地找到
goinstall:bytes:go / build:在本地找不到包
goinstall:log:go / build:pa ckage无法在本地找到
goinstall:encoding / binary:go / build:在本地找不到包
GOPATH
会被讨论在 cmd / go
文档中:
GOPATH
环境变量列出了查找Go代码的位置。在
Unix上,该值是冒号分隔的字符串。在Windows上,值为
分号分隔的字符串。在计划9中,该值是一个列表。
GOPATH
必须设置为在外部获取,构建和安装包
标准Go树
GOROOT
安装说明:
Go二进制发行版假设它们将安装在
/ usr / local / go
(或c:\ Go
在Windows下),但可以将
Go工具安装到其他位置。在这种情况下,您必须将
GOROOT
环境变量设置为指向安装
的目录。
例如,如果您安装了Go到您的主目录,您应该将
以下命令添加到$ HOME / .profile
: p>
export GOROOT = $ HOME / go
export PATH = $ PATH:$ GOROOT / bin
$注意:
GOROOT 安装到自定义位置。
( Chris Bunch的回答。)
I'm trying to install doozer like this
$ goinstall github.com/ha/doozer
I get these errors.
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
GOPATH
is discussed in the cmd/go
documentation:
The
GOPATH
environment variable lists places to look for Go code. On Unix, the value is a colon-separated string. On Windows, the value is a semicolon-separated string. On Plan 9, the value is a list.
GOPATH
must be set to get, build and install packages outside the standard Go tree.
GOROOT
is discussed in the installation instructions:
The Go binary distributions assume they will be installed in
/usr/local/go
(orc:\Go
under Windows), but it is possible to install the Go tools to a different location. In this case you must set theGOROOT
environment variable to point to the directory in which it was installed.For example, if you installed Go to your home directory you should add the following commands to
$HOME/.profile
:export GOROOT=$HOME/go export PATH=$PATH:$GOROOT/bin
Note:
GOROOT
must be set only when installing to a custom location.
(updated version of Chris Bunch's answer.)
这篇关于GOPATH和GOROOT的价值应该是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!