Google Go is a new language mixing some good things from python and c++, and is so far known for it’s fast and fun development. The Google Go installation guide is quite decent to follow on a mac, but terminal knowledge is required, because for instance they don’t mention all steps included. Below a brief step by step guide, which works well on Mac OS X Snow Leopard.

1. If you haven’t, go install XCode from your retail disk or from the download at Apple’s developer connection.
2. Open .
3. Go set up your shell variables. Somehow Go seems to prefer to be installed into the user’s home directory, but it can be installed system wide if you want. For now let’s just follow the official guide here.

Use your favorite editor to open ~/.profile, mine is nano.

nano ~/.profile

At the bottom part, you will have to add 4 entries, the rest of the variables will be assumed by the go compiler.

export GOROOT=$HOME/go
export GOARCH=amd64
export GOOS=darwin
export PATH=$HOME/bin:$PATH

Now save the file, in nano this is done by pressing ctrl-o.

4. Reload your profile.

source ~/.profile

5. Create the folder bin in your homedir, go will assume this by default. This can optionally be changed by setting GOBIN in your .profile .

mkdir $HOME/bin

6. Install mercurial, the versioning service hosting Go. When prompted type in your password, you are giving administrative access here.

sudo easy_install mercurial

7. Clone the repository to your local disk

hg clone -r $GOROOT

8. Now change into the source dir.

cd $GOROOT/src

9. Install the Go tools by running the following command:


10. You are all done now.

You can now proceed to writing your first hello world applications, this is written in a short summary on the Installing Go page, section Writing Programs.

Simple HelloWorld.go:

package main

import fmt "fmt"

func main() {
	fmt.Printf("Hello world\n");

If you want you can ease up development using a more common folder structure and a Makefile. I usually keep the following folder structure:

. – Holds Makefile, AUTHORS, CHANGELOG, LICENSE, etc..
./src – holds all source files
./build – intermediate folder for build files (mainly for the linker)
./bin – the binary files
./dist – optional folder where releases are being created, usually by copying stuff from the bin folder.

You can use the following Makefile as a starter if you want.

# Simple make file for Google Go applications
# -----------------------------------
# Make sure you have your go installation set up correctly and 6g and 6l are working properly

LINKER := 6l

default: core

	$(COMPILER) $(CFLAGS) -o build/HelloWorld.6 src/HelloWorld.go
	$(LINKER) $(LFLAGS) -o bin/HelloWorld build/HelloWorld.6
	rm -Rf build/*
	rm -Rf bin/*

Enjoy :).

Content written by Martijn de Boer. All content here may be quoted, linked to or summarized when linking to the original materials.