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.
To set GOPATH, open the bashrc/ bash_profle/zshrc file and type the following commands in it and then save the file. pkg − the directory that will contain the packages and shared object files if any. src − the directory where all the code you will write will be stored.
The GOPATH environment variable specifies the location of your workspace. It defaults to a directory named go inside your home directory, so $HOME/go on Unix, $home/go on Plan 9, and %USERPROFILE%\go (usually C:\Users\YourName\go ) on Windows.
Adding GOPATH environment variableCreate a new folder in your C drive called "C:\Projects\Go". Open Run dialog by pressing win + r and type the sysdm. cpl ,3 inside the run dialog. And then click OK.
You don't need to set the GOPATH, it is set by default. The GOPATH directory is also named a workspace. Instead of randomly placing your code somewhere, you can use the gopath src directory. This is a mistake many beginners make, placing their code anywhere on the computer.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With