GOPATH未保存[关闭]

I try do install golang on my laptop with Xubuntu 15.10. But the GOPATH will not be saved. After reopen the terminal the GOOPATH is not set. Anyone an idea how to fix it ?

I personally use GVM(Go Version Manager) on my linux boxes to handle gopaths

To install:

bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)

Restart your terminal and use:

apt-get install bison binutils build-essential
gvm install go1.5.2 -B
gvm use go1.5.2 --default

Your GOPATH will be set to $GOPATH and all "go get" will be in $GOPATH/src

This is by far the easiest way to play with golang IMO

You need to edit your $HOME/.profile script, and add the following lines:

export GOPATH=$HOME/go
export PATH=$PATH:$GOPATH/bin

for example.

Don't forget to logout/login after saving the file in order for the change to be taken into account.

Adjusting the PATH variable is necessary if you install programs via go get in your $GOPATH and want them to be executable directly from the terminal.