英文:
GOPATH environment variable not set
问题
我正在尝试按照这些说明安装Go的Oracle驱动程序(go-oci8)。
我遇到的问题是$GOPATH环境变量的问题。
当我执行以下命令时:
sudo go get github.com/mattn/go-oci8
我收到错误消息:
cannot download, $GOPATH not set. For more details see: go help gopath
然而,我已经正确设置了GOPATH。我的环境如下:
env | grep GO
GOARCH=amd64
GOROOT=/usr/local/go
GOOS=linux
GOPATH=/home/myuser/go/
ls $GOPATH
bin pkg src
我找到了一个类似的帖子,但解决方案不适用于我的情况。
英文:
I'm trying to install the Oracle Driver for Go (go-oci8) following these instructions
The problem I'm facing is with the $GOPATH environment variable.
When I execute the command:
sudo go get github.com/mattn/go-oci8
I get the error :
cannot download, $GOPATH not set. For more details see: go help gopath
However, I have the GOPATH properly set. My environment looks like this:
env | grep GO
GOARCH=amd64
<br>
GOROOT=/usr/local/go
<br>
GOOS=linux
<br>
GOPATH=/home/myuser/go/
<br>
ls $GOPATH
<br>
bin pkg src
I've found a similar post but the solution does not apply to my case.
答案1
得分: 8
sudo不会为了一些非常好的安全原因而使用您的所有环境变量。
修复这个问题的最简单方法是使用/bin/env
sudo /bin/env GOPATH=/home/myuser/go go get
但您不需要这样做,您真的不应该需要root权限来写入GOPATH,只需要GOROOT即可。
英文:
Sudo won't honor all your ENV variables for some very good security reasons.
The simplest way to fix this is /bin/env
sudo /bin/env GOPATH=/home/myuser/go go get <stuff>
But you don't need to do that, you really shouldn't need root to write
to GOPATH, only GOROOT.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论