2

I followed the linux go installation instructions and ran sudo tar -C /usr/local -xzf go$VERSION.$OS-$ARCH.tar.gz and added /usr/local/go/binto $PATH. Unfortunately, I am stuck because go ignores any attempt to export $GOPATH in the terminal. What's going on and how can I fix it?

$ export GOPATH=$HOME/Go
$ echo $GOPATH
/home/rsg/Go
$ go env
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH=""
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build834345994=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"

Edit: On further inspection, it seems that for some reason, I am unable to export GOPATH at all. I am not sure why, because exporting other variables (e.g. FOO) works just fine. What on earth is going on?

rsg@P ~ $ env | grep FOO
rsg@P ~ $ env | grep GOPATH
rsg@P ~ $ export FOO=bar
rsg@P ~ $ env | grep FOO
FOO=bar
rsg@P ~ $ export GOPATH=bar
rsg@P ~ $ env | grep GOPATH
rsg@P ~ $ GOPATH=foo env | grep GOPATH
GOPATH=foo
rsg@P ~ $ env | grep GOPATH
Antimony
  • 37,781
  • 10
  • 100
  • 107
  • have you read there? http://stackoverflow.com/questions/21001387/how-do-i-set-the-gopath-environment-variable-on-ubuntu-what-file-must-i-edit. Are you sure your `/home/rsg/Go` directory exists and has user permissions? – Jean-François Fabre Sep 03 '16 at 21:19
  • @Jean-FrançoisFabre yes and yes. The real mystery is why writing `export GOPATH=...` doesn't actually export the variable. – Antimony Sep 03 '16 at 21:25
  • Strange, all the guys who answered seemed to have that part okay ! can you `ls $GOPATH` ? (I mean: maybe `go` filters out directories that don't please it) – Jean-François Fabre Sep 03 '16 at 21:35
  • Running `unset GOPATH` seems to have fixed things. I have no idea why, but at least it works now. – Antimony Sep 03 '16 at 21:39

1 Answers1

0

I still have no idea what the problem was, but running unset GOPATH fixed it.

Antimony
  • 37,781
  • 10
  • 100
  • 107