Dec 022009
 

Here’s a simple quick tutorial on how to install Go Language from Google on the Mac OS X.

  1. Install XCode
  2. Install Macports
  3. Open Terminal and install mercurial from macports and wait.
    sudo port install mercurial
  4. Edit your .profile to include the Go environment variables. This is required to build the Go Language. Add the following:
    # wherever your Go source directory will be
    export GOROOT=$HOME/go
    # or 386 but it is recommended to use amd64
    export GOARCH=amd64
    export GOOS=darwin
    # export GOBIN=$HOME/bin # it will install the Go compiler here by default.
    # add the $GOBIN into your path environment if you want to.
    # export PATH=$GOBIN:$PATH
  5. Open a new Terminal to refresh the environment variables.
  6. Download the Go Language source codes
    hg clone -r release https://go.googlecode.com/hg/ $GOROOT
  7. Change directory to $GOROOT
    cd $GOROOT/src
  8. Build the source
    ./all.bash
  9. If there are no errors it will show the following:
    — cd ../test
    N known bugs; 0 unexpected bugs
  10. You can start using it now! 6g is the compiler filename for amd64 and 8g is the compiler filename for 386.

To update the source:

  1. Change directory to $GOROOT
    cd $GOROOT/src
  2. Update the source
    hg update
  3. Build the source
    ./all.bash
  4. If there are no errors it will show the following:
    — cd ../test
    N known bugs; 0 unexpected bugs

Related posts:

  1. Phalanger – the PHP Language Compiler for .NET Framework
  2. Windows Media Player Plugin for Firefox on Windows Server 2008
  3. Problems installing VSTS 2005 Dec. 2004 CTP
  4. Boo – New .NET Language
  5. Practical Session : Visual Source Safe on SCCBridge
  • http://nttup.wordpress.com NTT

    Nice.. I am installing it right now.

    I hit on one error with mercurial..

    “File “/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/locale.py”, line 410, in _parse_localename
    raise ValueError, ‘unknown locale: %s’ % localename

    Python can’t find ‘Locale’.

    You can fix this by setting the LANG and LC_ALL environmental variables to UTF8.

    #export LANG=UTF8
    #export LC_ALL=UTF8

    I got the tip from

    http://old.nabble.com/-MacPorts—20730:-Mercurial-appears-to-require-LANG-and-LC_ALL-set-to-UTF8-td25039324.html

  • http://nttup.wordpress.com NTT

    OK. One more hurdle for OSX 10.5 install. If you’re default OSX user account is not admin (and it shouldn’t be!!) The you’ll need to do some more env variable settings to allow go to compile.. This will allows your GO environment variables to exist when you sudo..

    “You have to add the GO* environment variables to /etc/
    sudoers and add to the Defaults list with
    (Defaults env_keep += “GOROOT GOBIN GOOS GOBIN GOARCH”)
    so they are maintained when you run sudo.”

    Got it from http://groups.google.com/group/golang-nuts/browse_thread/thread/6db568d839310301/141ad6051469d289?lnk=gst&q=quietgcc#141ad6051469d289

  • http://www.justinlee.sg Justin Lee

    Oh? I didn’t use sudo to build the source. You needed to use sudo to compile?

  • http://nttup.wordpress.com NTT

    Yes.. Maybe cos of where I pointed GOBIN to.. Also I don’t run as an Admin account..