-1

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 ?

Balouh
  • 13
  • 2
  • 1
    Take a look at this answer for a different question. http://stackoverflow.com/a/26962251/450989 I mention where to put GOPATH. – Grzegorz Żur Jan 05 '16 at 13:35

2 Answers2

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
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