Saturday, November 14, 2009

Getting Google's "go" language compiler set up on OSX (Snow Leopard)

Here are my rough notes for getting google's go compiler set up on Snow Leopard (applies to any 64 bit macbook). These steps are mostly outlined on http://golang.org/doc/install.html, although there are a couple of extra steps I needed to make, which I'm listing here:

1. If you haven't already, install XCode so you have the gcc compiler:
http://developer.apple.com/technology/xcode.html

2. Install mercurial (if you don't already have it):

sudo easy_install mercurial


3. Configure your environment variables and run the setup - open the terminal and in your home directory edit .profile and add the following:

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

Run source .profile if you want to use those values without restarting (otherwise just close the terminal and reopen it)

4. check out go from the mercurial repository

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


5. run the setup:

mkdir $HOME/bin
cd $GOROOT/src
./all.bash


6. Write out the obligatory hello world code (hello.go):

package main

import "fmt"

func main() {
fmt.Printf("hello, world\n")
}


7. Compile, link and run:

6g hello.go
6l hello.6
./6.out


Adapted from: http://golang.org/doc/install.html

0 comments:

Blog Archive

About Me