好的,所以我已经下载了 Go 1.1 并将其放入 $HOME/Documents/go 中。
然后,我将我的修改.bashrc
为:
export GOPATH=$HOME/Documents/go
export GOROOT=$GOPATH
export GOARCH=amd64
export GOOS=linux
export GOBIN=$GOPATH/bin
export PATH=$PATH:$GOBIN
比我采购的.bashrc
,并尝试过:
jan@janpc:~$ go version
go version go1.1 linux/amd64
但我无法让它编译或安装任何依赖项。例如。我尝试运行我的小测试程序:
jan@janpc:~/Documents/go/src/github.com/jan/scrypt$ go run scrypt.go
warning: GOPATH set to GOROOT (/home/jan/Documents/go) has no effect
scrypt.go:9:3: cannot find package "github.com/dchest/scrypt" in any of:
/home/jan/Documents/go/src/pkg/github.com/dchest/scrypt (from $GOROOT)
($GOPATH not set)
jan@janpc:~/Documents/go/src/github.com/jan/scrypt$
当我尝试安装依赖项时:
jan@janpc:~/Documents/go/src/github.com/jan/scrypt$ go get "github.com/dchest/scrypt"
warning: GOPATH set to GOROOT (/home/jan/Documents/go) has no effect
package github.com/dchest/scrypt: cannot download, $GOPATH must not be set to $GOROOT. For more details see: go help gopath
它可以在 mac 上编译并正常工作。如果我尝试删除$GOROOT
或$GOPATH
没有任何效果,我无法弄清楚我的配置有什么问题,而且除了 Go 的路径之外,我不知道还能将它们设置为什么。
编辑:我的 Mac 上没有设置 $GOROOT。但是,如果我在 ubuntu 上删除$GOROOT
,我会在尝试编译时遇到类似这样的错误。
cannot find package "fmt" in any of:
/usr/local/go/src/pkg/fmt (from $GOROOT)
/home/jan/Documents/go/src/fmt (from $GOPATH)