GOPATH环境变量未设置

huangapple go评论124阅读模式
英文:

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 &lt;stuff&gt;

But you don't need to do that, you really shouldn't need root to write
to GOPATH, only GOROOT.

huangapple
  • 本文由 发表于 2013年11月8日 16:45:55
  • 转载请务必保留本文链接:https://go.coder-hub.com/19854835.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定