Life In The Stack Trace...

TODO: <Insert clever marketing phrase here>

Installing Go on Ubuntu (Quantal) 12.10

The Go Language appeared on my radar sometime in 2009. It looked very impressive, however, my thinking at the time was to let it ride a little while and wait for it to mature a bit more. Today, I'm starting to look at it a little. For me, step one is install and start playing around.

Ya know, you gotta love it when you read and follow some instructions and it actually works!! However, all of my blog posts include timestamp information, so, it worked at the time of this writing!!

I followed the instructions at the following link: http://golang.org/doc/install#install

Find a tarball to download at: http://code.google.com/p/go/downloads/list

Download a tarball

wget http://go.googlecode.com/files/go1.2.1.linux-amd64.tar.gz

Expand it

sudo tar -C /usr/local -xzf go1.2.1.linux-amd64.tar.gz

Add go bin directory /usr/local/go/bin to the PATH environment variable.

# edit .profile in your home directory
nano ~/.profile

# add the following line
export PATH=$PATH:/usr/local/go/bin

For system-wide installation

# edit .profile in your home directory
nano /etc/profile

# add the following line
export PATH=$PATH:/usr/local/go/bin

Normally, you would have to logout of your system and log in again for the changes to take effect, however, you have the option of reloading .profile

source ~/.profile

or

source /etc/profile

Test your installation

# notice that you don't have to prefix version with a hyphen "-"
go version

# my output was
go version go1.2.1 linux/amd64
  • Custom install

On linux systems, Go assumes to be installed in /usr/local/go, however, you have the option to install anywhere you wish. The only requirement is to set the GOROOT environment variable to point to your custom install directory. Let's say you decided to install go in your /home directory on your linux box. Let's also assume the user name is: demo

# change to your home directory (assuming user name is demo)
cd ~
tar -xzf go1.2.1.linux-amd64.tar.gz

# edit .profile in your home directory
nano ~/.profile

# add the following line(s)
# here, we are setting GOROOT
export GOROOT=$HOME/go
export PATH=$PATH:/home/demo/go/bin

source .profile

Test your installation

# notice that you don't have to prefix version with a hyphen "-"
go version

# my output was
go version go1.2.1 linux/amd64