Thursday, August 15, 2013

Installing and Configuring Go


In preparation for a few beginner workshops, I created videos for people to follow to install and configure the Go development tools. Just adding them here.

On Mac OSX:


On Ubuntu Linux:


The steps that I've followed are pretty much this (with my username 'vj'):
  • Download the zip or .tar.gz file for your platform from https://code.google.com/p/go/downloads/list
  • Create a folder called golang wherever you prefer. I prefer to have it in my home folder like so: /home/vj/coding/golang since I want to keep all my programming language folders in a "coding" folder in my home dir.
  • Extract the .zip or .tar.gz file you downloaded earlier. It will contain a single "go" folder. Move this into your golang folder. So you will now have something similar to /home/vj/coding/golang/go
  • Append the path to the go command line tools (/home/vj/coding/golang/go/bin) to your $PATH. On Ubuntu in my bash shell, to ~/.bashrc I added the entry export PATH=$PATH:/home/vj/coding/golang/go/bin
  • I created one new folder in the golang folder called gopath". The Go tools will have use for this path later to download and install external packages.
  • Add two additional entries to your .bashrc, export GOROOT=/home/vj/coding/golang/go and export GOPATH=/home/vj/coding/golang/gopath
  • Source the .bashrc if required so that the environment variables are available in your current shell, or restart the shell.

With that you should now be ready to compile and run your go programs. Note that you don't need any special editors or IDEs to work with Go. All your regular text editors will work.
The process to be followed for Windows is pretty much the same. You can have your golang folder as c:/coding/golang and add your environment variables as you would normally do on windows: right click My Computer -> Click Properties -> Click Advanced System Settings -> Click Environment Variables. Add new GOROOT and GOPATH values, and append the required value to the Path variable.