oracle 未设置 GOPATH 环境变量

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19854835/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 02:04:26  来源:igfitidea点击:

GOPATH environment variable not set

linuxoraclegooci

提问by Jose Bagatelli

I'm trying to install the Oracle Driver for Go (go-oci8) following these instructions

我正在尝试按照这些说明安装 Oracle Driver for Go (go-oci8)

The problem I'm facing is with the $GOPATH environment variable. When I execute the command:

我面临的问题是 $GOPATH 环境变量。当我执行命令时:

sudo go get github.com/mattn/go-oci8

sudo go get github.com/mattn/go-oci8

I get the error :

我收到错误:

cannot download, $GOPATH not set. For more details see: go help gopath

cannot download, $GOPATH not set. For more details see: go help gopath

However, I have the GOPATH properly set. My environment looks like this:

但是,我正确设置了 GOPATH。我的环境是这样的:

env | grep GO

env | grep GO

GOARCH=amd64
GOROOT=/usr/local/go
GOOS=linux
GOPATH=/home/myuser/go/

GOARCH=amd64
GOROOT=/usr/local/go
GOOS=linux
GOPATH=/home/myuser/go/

ls $GOPATH
bin pkg src

ls $GOPATH
bin pkg src

I've found a similar postbut the solution does not apply to my case.

我发现了一个类似的帖子,但该解决方案不适用于我的案例。

回答by Fred the Magic Wonder Dog

Sudo won't honor all your ENV variables for some very good security reasons.

出于一些非常好的安全原因,Sudo 不会尊重您的所有 ENV 变量。

The simplest way to fix this is /bin/env

解决此问题的最简单方法是 /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.

但是你不需要这样做,你真的不需要 root 来写入 GOPATH,只需要 GOROOT。