Go Help

Go Installation Notes


I found that there were some common problems that people were having while attempting to install Google Go from the instructions on the Golang.org site at http://golang.org/doc/install.html.  Follow their procedures, but, here I provide some notes that I hope will save you some thrashing.  Here is a link to another installation tutorial:  http://maketecheasier.com/install-google-go-in-ubuntu/2010/04/15.

Environment Variables

The Go instructions say to put the environment variables $GOROOT, $GOOS, $GOARCH and $GOBIN (if you choose to use it) in $HOME/.bashrc.  This only sets them for the current user in an interactive terminal.  If you write a script that calls another script, they will probably not be found.  For reasons lost in obscurity, a non-interactive terminal does not necessarily inherit the current user environment.  The scripts in the ‘Gedit – An IDE for GO’ tutorial use non-interactive terminal sessions and will probably not work.  You will save yourself some trouble if put your environment variables in your $HOME/.profile, it does get read by a non-interactive terminal.  Also, if you have a computer that you wish to share with others, you should set these higher up in the initialization process, for example /etc/profile or whatever your distribution uses.

The above also applies to your $PATH variable.  Be sure that you have it set to the location where you want the Go binaries installed.  The default is $HOME/bin.  Example: PATH=$PATH:$HOME/bin.  Some systems will already set this in $HOME/.profile.  Check yours.

After you have done the above, log out and re-login to be sure that everything is properly set.  Then open a terminal and type env, to check that everything is ready to go.  Pun intended.

Fetch the Go Repository

Install the Mercurial source code control package.  In Ubuntu 9.10, Mercurial is in the repositories.  Goto System/Administration/Synaptic Package Manager and type in Mercurial to find it.  Under Ubuntu 9.10, the repositories install version 1.3.x.  This seems to work fine, but if you want the latest version of  Mercurial 1.4.x, here is the link:    https://launchpad.net/~mercurial-ppa/+archive/releases.  When you get there, go down and click Technical details about this PPA.  Just below that will come up Read about Installing.  Click this and follow the instructions in the pop up window.

After Mercurial is installed you can continue with the Go instructions, at a terminal type:

hg clone -r release https://go.googlecode.com/hg/ $GOROOT

This runs the Mercurial clone command and creates an exact copy of Googles development site on your computer.

Install Go

Go has several other dependencies.  You can use the sledge hammer approach and at a terminal type:

sudo apt-get install bison gcc libc6-dev ed gawk make

or you can first check your repositories.  Ubuntu 9.10 installs gcc, libc6-dev, ed, gawk and make by default.  So you only have to Goto System/Administration/Synaptic Package Manager and load bison(a parser generator).  But double check that you have them all.

Follow the rest of the Go install.  If it doesn’t finish properly, the most common problems are the environment and path variables, so check them again.

Other Linux distributions

I use Ubuntu 9.10, so I am not an expert on other distributions, but there is an installation guide I found for Novell Suse Linux here.

Blog at WordPress.com.

%d bloggers like this: