英文:
Go: Install package with -u command
问题
我正在尝试通过运行以下命令来安装一个Go包(https://github.com/jteeuwen/go-bindata#installation):
go get -u github.com/jteeuwen/go-bindata/...
我遇到了这个错误:
package github.com/jteeuwen/go-bindata/...: 无法下载,$GOPATH未设置。有关详细信息,请参阅:go help gopath
我的GOPATH已经按照普通方式设置了。我理解这是由于-u命令引起的...我该如何解决这个问题?
英文:
I'm trying to install a Go package (https://github.com/jteeuwen/go-bindata#installation) by running this command
go get -u github.com/jteeuwen/go-bindata/...
I get this error:
package github.com/jteeuwen/go-bindata/...: cannot download, $GOPATH not set. For more details see: go help gopath
My GOPATH is set in the ordinary way. I understand this is caused by the -u command... how do I resolve this?
答案1
得分: 0
这取决于你的操作系统,但请确保在你的.bashrc
文件中设置了GOPATH
(参考这个问题),或者至少设置为:
export GOPATH=/home/<username>/go
这样,其他进程(如go get
)将继承该变量。
在Windows上,你可以在用户环境变量中声明该变量。
要检查已设置的内容("打印Go环境信息"):
go env
如果变量已经设置,但仍然无法进行go get -u
,那么可能类似于问题42:
你的问题是你已经将Go安装到了一个需要特权升级才能安装的位置。
还要检查你的GOROOT
和Go的安装位置。
英文:
It depends on your OS, but make sure your GOPATH
is set in your .bashrc
(as in this question) or least set with
export GOPATH=/home/<username>/go
That way, other processes (like go get
) will inherit that variable.
On Windows, you would declare that variable in your user environment variables.
To check what is already set ("Print Go environment information"):
go env
If the variable is already set, but a go get -u still fails, then this could be similar to issue 42:
> Your issue is that you have installed go to a location that requires privilege escalation to install to.
Check also your GOROOT
and where go is installed.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论