我在 Mac OS X 中安装了 Go 1.4。以前我有 Go 1.0。我将 GOROOT 和 PATH 设置如下,
Dineshs-MacBook-Air:go-cassandra Dany$ which go
/usr/local/go/bin/go
Dineshs-MacBook-Air:go-cassandra Dany$ export GOROOT=/usr/local/go/bin/go
Dineshs-MacBook-Air:go-cassandra Dany$ export PATH=$PATH:$GOROOT/bin
Go 安装在 '/usr/local/go/bin/go' 中。我将 GOPATH 设置为我的项目 src 目录。我可以在我的目录中运行 go 代码。但是当我尝试安装 gocql 时出现错误。
Dineshs-MacBook-Air:go-cassandra Dany$ sudo go get github.com/gocql/gocql
package github.com/gocql/gocql: cannot download, $GOPATH not set. For more details see: go help gopath
有人可以帮我吗?谢谢
编辑 1: @VonC 我也尝试了其他选项。我把GOROOT改成go安装的目录。但这没有帮助。我改变了 GOPATH。
Dineshs-MacBook-Air:go-cassandra Dany$ export GOROOT=/usr/local/go
Dineshs-MacBook-Air:go-cassandra Dany$ export PATH=$PATH:$GOROOT/bin
Dineshs-MacBook-Air:go-cassandra Dany$ export GOPATH=/Users/Dany/Documents/FALL-2013-COURSES/Imp_Data_structures/workspace/go-cassandra
Dineshs-MacBook-Air:go-cassandra Dany$ sudo go get github.com/gocql/gocql
Password:
package github.com/gocql/gocql: cannot download, $GOPATH not set. For more details see: go help gopath
Dineshs-MacBook-Air:go-cassandra Dany$ echo $GOPATH
/Users/Dany/Documents/FALL-2013-COURSES/Imp_Data_structures/workspace/go-cassandra
Dineshs-MacBook-Air:go-cassandra Dany$ ls
bin pkg src
Dineshs-MacBook-Air:go-cassandra Dany$