Google’s Newest Toy – Installing Go in Ubuntu 9.10

Setting up Google Go in Ubuntu 9.10

Google Go

Google Go

Go is Google’s newest offering to the development community.  According to the project’s page, Go is an expressive, concurrent, garbage collected programming language that is simple, fast, safe, concurrent, fun and (best of all) open source. Touted as a cross between C/C++ and Python, Go seems to be generating a lot of buzz and hoards of seemingly early adopters despite having surfaced only earlier today (11.10.2009) .  Of course this is somewhat expected – what has Google ever released that didn’t generate it’s share of hype/buzz/excitement associated with it?

I bit.  I am guessing since you are reading this, you did too.

Getting Ready to Go

EDIT:  For more updated discussion on this, please head to my thread on Ubuntu Forums – http://ubuntuforums.org/showthread.php?t=1322518

The following instructions detail the steps that I used to setup Go on my x64 Ubuntu 9.10 (Karmic Koala) box.

Standard disclaimer: Your mileage may vary.  For me everything was pretty much straight forward when following the maintainer’s provided setup instructions (http://golang.org/doc/install.html). The only hiccup I encountered during setup was an error with a test during make – Error 2 in [net.test]. A quick bounce over to #go-nuts resolved that – friendly go-nut knowledge base, iant, advised me that there was an issue with this test on some machines in the release version and that I should pull an update. Update pulled, problem fixed.

For simplicity sake, I am working from the gnome-terminal. Access bash as you see fit.  When you see ‘$’, it denotes a command to enter in the CLI (Command Line Interface).  When you see ‘>’, it denotes and output line.

FYI – My Machine Info:

$uname -a
>2.6.31-14-generic #48-Ubuntu SMP Fri Oct 16 14:05:01 UTC 2009 x86_64 GNU/Linux

Installing Required Tools

Install Python Setup Tools if not installed – Makes installing Mercurial in Ubuntu easy.

$sudo apt-get install python-setuptools

Install Mercurial (using your newly installed Python Setup Tools):

$sudo easy_install mercurial

Install GCC (to build Go):

$sudo apt-get install bison gcc libc6-dev


Setting Up Your Environment

1) Make ‘bin’ directory for go – You may have one – this will create it for you if you don’t:

$mkdir ~/bin

2) Setting up environmental variables:

Edit your Bash environment variables to include the Go required variables as well as making sure your bin folder is in the $PATH

$cp ~/.bashrc ~/.bashrc.bu
$gedit ~/.bashrc

Add following to your .bashrc:

#Google Go Vars
export GOROOT=~/go
export GOOS=linux
export GOARCH=amd64
PATH=${PATH}:$HOME/bin

Reload .bashrc

$source .bashrc

Note: You can close your terminal session and restart terminal instead. Up to you.

Check out Go ( to your Go root using Mercurial)

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

Note: I had to pull an update due to errors during make (details below with build instructions):

$cd $GOROOT
$hg pull -u

Build Go

$cd $GOROOT/src
$./all.bash

If successful, results should be:

>— cd ../test
>0 known bugs; 0 unexpected bugs

Note on make errors: Before pulling an update on the repository, make resulted in:

>make[1]: Leaving directory `/home/eznet/go/src/pkg/net’
>make: *** [net.test] Error 2

Updating via the ‘hg pull -u’ command above resolved this issue and allowed make to complete as desired.

GO play with Go

Tutorial: http://golang.org/doc/go_tutorial.html

5 comments

  1. I get:

    — FAIL: net.TestDialGoogle
    — 74.125.19.99:80 —
    http://www.google.com:80
    Dial(“tcp”, “”, “www.google.com:80”) = _, dial tcp http://www.google.com:80: lookup http://www.google.com. on 192.168.1.254:53: no answer from server
    Dial(“tcp4”, “”, “www.google.com:80”) = _, dial tcp4 http://www.google.com:80: lookup http://www.google.com. on 192.168.1.254:53: no answer from server
    Dial(“tcp4”, “”, “www.google.com:80”) = _, dial tcp4 http://www.google.com:80: lookup http://www.google.com. on 192.168.1.254:53: no answer from server
    Dial(“tcp6”, “”, “www.google.com:80”) = _, dial tcp6 http://www.google.com:80: lookup http://www.google.com. on 192.168.1.254:53: no answer from server
    — 74.125.19.99:http —
    http://www.google.com:http
    Dial(“tcp”, “”, “www.google.com:http”) = _, dial tcp http://www.google.com:http: lookup http://www.google.com. on 192.168.1.254:53: no answer from server
    Dial(“tcp4”, “”, “www.google.com:http”) = _, dial tcp4 http://www.google.com:http: lookup http://www.google.com. on 192.168.1.254:53: no answer from server
    Dial(“tcp4”, “”, “www.google.com:http”) = _, dial tcp4 http://www.google.com:http: lookup http://www.google.com. on 192.168.1.254:53: no answer from server
    Dial(“tcp6”, “”, “www.google.com:http”) = _, dial tcp6 http://www.google.com:http: lookup http://www.google.com. on 192.168.1.254:53: no answer from server
    — 074.125.019.099:0080 —
    — [::ffff:74.125.19.99]:80 —
    — [::ffff:4a7d:1363]:80 —
    — [0:0:0:0:0000:ffff:74.125.19.99]:80 —
    — [0:0:0:0:000000:ffff:74.125.19.99]:80 —
    — [0:0:0:0:0:ffff::74.125.19.99]:80 —
    FAIL
    make[1]: *** [test] Error 1
    make[1]: Leaving directory `/root/go/src/pkg/net’
    make: *** [net.test] Error 2

  2. Really nice post..i had problem in installing go when i used Go tutorial..Your tutorial just works for me …except i can install mercury as u specified but i installed it with other tool..Thank you for posting..

Leave a Reply to Amol Cancel reply

Your email address will not be published. Required fields are marked *