简体   繁体   中英

GOPATH environment variable not set

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
GOROOT=/usr/local/go
GOOS=linux
GOPATH=/home/myuser/go/

ls $GOPATH
bin pkg src

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM