Installing Go on OSX Snow Leopard

| | Comments (7) | TrackBacks (0)
Go is a new experimental language that has been released by Google that is suppose to have nearly the speed of C while executing, without a lot of the normal headaches of C/C++ coding.  For example Go has garbage collection, dynamic types, reflections, etc. see Google Experiments With A New Language, Go for a good overview.  So after reading a few things about it, I wanted to try it out, and here is how I got it working on my 64-bit OSX machine.

It's pretty basic, all I did was follow the instructions here.

First I added:

export GOROOT=$HOME/go
export GOOS=darwin
export GOARCH=amd64
export GOBIN=$HOME/gobin
export PATH=$PATH:$GOBIN
to ~/.bash_profile

Run:

. ~/.bash_profile
Next:

sudo easy_install mercurial
This took a while for me to pull mercurial down, maybe their server was having problems.

Note: I had to install the Xcode.mpkg from the Optional Installs on my Snow Leopard DVD to get gcc-4.3 installed.

Next:

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

cd $GOROOT/src
./all.bash
Note: One of the http tests goes out and touches google.com, I had to drop the firewall while building everything.  After the build and tests were complete I turned it back on.

And that's it! Time to make a hello world program.

Create hello.go:

package main

import fmt "fmt"

func main() {
   fmt.Printf("hello world!\n");
}
Compile and Link:

6g hello.go
6l hello.6
Run:

./6.out
Output:

hello world!
I am very excited about Go can't wait to write something real with it!

7 Comments

alorenzo said:

why did you have to drop the firewall? we need to be able to install GO behind a firewall.
http_proxy does not work, what command/setting should we use?

green tea said:

Snow Leopard has arrived and we know how Important is it for you to upgrade. The excitement of the OSx86 has risen to levels where every one needs to run the latest Mac OS X and Snow Leopard is but obvious.

Mk12 said:

Why does it have to install in ~/go ? Can I hide it away in /usr/local like everything else?

tam said:

In osx I had to

mkdir $GOBIN

before running

./all_bash

Thanks for the post.

Oscar said:

Hello.

I tried the same but I got this error while compiling mercurial

mercurial/base85.c:12:20: error: Python.h: No such file or directory


What I do understand is that I need python-dev, but I thought that was installed within Xcode

What should I look at?

Erick said:

Hi,
I've been trying for several days to get Go installed on my Mac, and after slogging through everything I could find on how to get this installed, I am completely stuck. This is the error that I get:

sol:src hcc$ ./all.bash
./env.bash: line 41: gmake: command not found
Did not find Go environment variables.

Now I know that I have the variables setup correctly and checked them all. My guess is that gmake is not on my system. But, everything I could find about how to get gmake on my system didn't work and I was getting some TCL library errors. I come from a Visual Studio background where all of this is taken care of but I would love to give this a go (yes, pun intended) if I could just get this up and running. Any help would be very appreciated!

Thanks.

Erick

Erick said:

Hi,
I've been trying for several days to get Go installed on my Mac, and after slogging through everything I could find on how to get this installed, I am completely stuck. This is the error that I get:

sol:src hcc$ ./all.bash
./env.bash: line 41: gmake: command not found
Did not find Go environment variables.

Now I know that I have the variables setup correctly and checked them all. My guess is that gmake is not on my system. But, everything I could find about how to get gmake on my system didn't work and I was getting some TCL library errors. I come from a Visual Studio background where all of this is taken care of but I would love to give this a go (yes, pun intended) if I could just get this up and running. Any help would be very appreciated!

Thanks.

Erick

Leave a comment

0 TrackBacks

Listed below are links to blogs that reference this entry: Installing Go on OSX Snow Leopard.

TrackBack URL for this entry: http://www.nearinfinity.com/mt/mt-tb.cgi/1534