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 ?
Asked
Active
Viewed 1,772 times
2 Answers
3
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.
SirDarius
- 39,072
- 8
- 82
- 98
-
-
1
-
instead of login/logout you can run `source $HOME/.profile` in terminal – aacanakin Jan 05 '16 at 15:57
-
@aacanakin yes that works for the current terminal, but if OP opens another one without logging out and back in first, it will have to be done manually again, giving the impression that editing the file was ineffective. – SirDarius Jan 05 '16 at 16:31
0
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
Ozzadar
- 458
- 1
- 3
- 10
-
it works nice. but their is stil a problem. We habe to work with liteide. and liteide can not find the gopath – Balouh Jan 05 '16 at 14:00
-
I don't use liteide personally but I did a quick search into it and it looks like you can __sudo nano /usr/share/liteide/liteenv/linux*.env__ and change your gopath in there. The full path is **/home/{user}/.gvm/pkgsets/go1.5.2/global/** – Ozzadar Jan 05 '16 at 14:10
-
@Balouh: You don't need GVM. It might be a nice tool for some, but you really need to know basics like how to set a simple environment variable, as you will need it again, e.g. adding GOBIN to your PATH. – JimB Jan 05 '16 at 15:02
-
Though I agree that one should learn to set up environment variables; the reason I suggest GVM when setting up your go environment is because no matter what linux distro you're on gvm takes care of your go environment for you and allows you to test against different versions of go without having to manually change any go env variables. – Ozzadar Jan 05 '16 at 15:24
-
yeah i had tro set the GOROOT in liteide. thanks guuys. i am new to linux an go so had a realy hard day to set things up – Balouh Jan 05 '16 at 20:09