Go : go get $GOPATH error, when GOPATH is set
environment-variables, go, macos, osx-mavericks
Solution
sudo go get github.com/go-sql-driver/mysql
This runs `go get` under `root` user, which does not have `$GOPATH` set.
Just do:
go get github.com/go-sql-driver/mysql
Generally, do:
go get
in the project folder, and it will install all dependencies. The following will install dependencies mentioned in tests:
go get -t
Problem
When running the go get command : ``` sudo go get github.com/go-sql-driver/mysql ``` I get the following error package github.com/go-sql-driver/mysql: cannot download, $GOPATH not set. For more details see: go help gopath However $GOPATH is already set. Running `echo $GOPATH` gives `/Users/userxyz/Desktop/Code` Running `go env` gives ``` ..... GOPATH="/Users/userxyz/Desktop/Code" ... GOROOT="/usr/local/go" ..... ``` I have already tried setting GOPATH as an environment variable by adding the following lines ``` export GOPATH="$HOME/Desktop/Code" export PATH=$PATH:$GOPATH/bin ``` to the following files, alternatively ``` ~/.profile (/etc/profile) ~/.bashrc ~/.bash_profile ```