Sunday, June 2, 2013

Installing Go, Gocode, GDB and LiteIDE

I removed the sections about gocode and GDB. These are not necessary any longer. I also added links for more editors.

This is a great post by Wade Wegner for installing Go on your Windows Machine:

Mac OS X
The following instructions will guide you through installing Go on your Mac.

Step 1: Download Go

Open your favorite browser and go to the following website:

This will show you all the latest builds for the different operating systems. Darwin is the name for the Mac OS. Download the installer package for your OS version and architecture.

Once downloaded go to your Downloads folder in Finder and double click on the pkg file to start the installation. The installation will put Go in /usr/local/go. Once the installation is complete you will want to check the installation.

Note: Moving forward we will be using both Terminal and Finder. It helps to be able to see all the files in Finder.  Finder by default will not show you everything that is on your hard drive.

To show all files in Finder:

Open a Terminal session. If you don't know where the Terminal program is go to your Applications folder in Finder and then Utilities. Click on Terminal and a bash shell command window will open.

Execute the following commands in Terminal.

defaults write AppleShowAllFiles TRUE
killall Finder

The killall Finder will reload the Finder program and now you can see all the files.

Step 2:  Check Installation

Open a Terminal session and type the following command

go version

You should see the following if everything installed correctly

go version go1.5 darwin/amd64

Now type the which command to verify the installation is in /usr/local/go

which go

You should see that Go can be found in /usr/local/go/bin


Step 3:  Set Your GOPATH

You need a single place to store and work on your Go projects. Create a folder called projects from inside your home folder:

cd $HOME

mkdir projects
cd projects
mkdir src
mkdir bin

Now set projects as your GOPATH. Open the .bash_profile file from the $HOME folder and add the following items to the end.

nano .bash_profile

export GOPATH="$HOME/projects"
export PATH=$PATH:$GOPATH/bin

Then exit the Terminal App and open a new Terminal App. Check that the Go environment now has your new GOPATH.

go env

You should see all the Go related environment variables including GOPATH. Here are some of them:


Step 4:  Get, Build and Install Basic Packages

These are Go packages you may want:

// gocode is used by many editors to provide intellisense
go get

// goimports is something you should run when saving code to fill in import paths
go get

// gorename is used by many editors to provide identifier rename support
go get

// oracle is a tool that help with code navigation and search
go get

// golint should be run after every build to check your code
go get

Step 5:  Debugger

Using GDB is really not an option. If you would like to experiment with Delve, here is a link:

Step 6: Install Editor


DisposaBoy wrote this plugin for Sublime

Mark Wolfe wrote this post:


Victor Farazdagi wrote this post on installing Vim for Go:


Joe Fitzgerald wrote this plugin for Atom


This is the configuration Guillaume Charmes uses:

Helpful Links

Here are other links to web pages that will be very helpful:

You must watch these videos on Go Concurrency Patterns


  1. Debugging worked after a few additional steps to these instructions.
    1. sudo chgrp procmod /usr/local/bin/gdb
    2. sudo chmod g+s /usr/local/bin/gdb
    3. add the legacy switch -p to taskgated by modifying the file /System/Library/LaunchAgents/
    4. Force kill taskgated process (it will restart) or reboot if necessary
    5. Try again

    Solution comes from this stackoverflow thread:

    ALERT! Be sure to use standard .plist markup with the file modification. Otherwise osx won't start next time you reboot. This happened to me. Solution to this is to reboot with recovery option (Cmd-R) and modifying the file with vi to match the standard.

    1. Karl, can you tell me what problems you experienced or what didn't work for you that required these steps. I would like to add these steps to the document. I didn't run into these problems. I am running version 10.8.4 of the Mac OS.

  2. I got this error from debug console from Lite-IDE --> "Unable to find Mach task port for process-id 12383: (os/kern) protection failure (0x2).\n (please check gdb is codesigned - see taskgated(8)". This error came even though I had codesigned gdb 7.6 with the exact steps of your instructions. Now I can reproduce the error by unloading the /System/Library/LaunchDaemons/, deleting the -p switch and reloading taskgated. My Mac OS is same as yours.

    The problem has to do with codesigning, but I can't figure out in what way.

    1. Thank Karl, I have added the error your identified and the solution to the post

  3. Great article! I only ran into one problem when builing and running LiteIDE test_program. "Errno 13." This is due to the gcc compiler that comes with XCode ~4.1.

    If anyone runs into Errno 13 please go here "Apple Discussion"

    1. Thank Alejabdro, I have added the error you identified and the solution to the post

  4. Thanks this was a great help.

  5. I ran into one small problem with the codesign command: gdb: cannot find code object on disk.
    Turns out codesign_allocate moved:
    export CODESIGN_ALLOCATE="/Applications/"

    The locate command found it for me (as well as regular use of /usr/libexec/locate.updatedb).

    1. Thanks for the update. I have made the change. The latest update of Xcode changed the location. I really appreciate it !!

  6. Thanks for the outstanding walk-through. I tripped over the nomenclature for "users" folder a couple of times, and simply guessed. Also, I was unable to get the line-8 green arrow rendered, and I have some work to do on getting the debugger working. I am using an early-1989 iMac, so darwin32-local was necessary for me to do a build; and I was using OSX 10.8.3 with the latest compatible XCode.

    Overall, really extraordinary job.

    Many thanks,


    1. I did focus the article on a 64-bit architecture, sorry about that. I am glad it had enough to get you going. If you have any questions send them to me.

    2. I wrote this back when I knew nothing about the os. I fixed all the references to user directory to home. Thanks again !!

  7. If you are into brew[0], the installation of go is dead simple[1] and I've found the upgrade process painless. GDB[2] is still a bit of a pain.

    [0] :
    [1] : "brew install go gdb"
    [1] ;

  8. Thanks for this walk-through. Having an integrated debugger is my main reason for using an IDE, instead of just an editor and Make, and after this I was up and running!

    You spent a big chunk of the post fiddling with the .bashrc file and PATH variable. There's a much easier way to do this on *nix systems (including OS X): edit the /etc/paths file. In this case you want the line "/usr/local/bin" to be before "/usr/bin". And you can add an entry for /usr/local/bin if it doesn't exist.

    1. Thanks for the tip on the /etc/paths file. I knew about that file. Beware that debugging on the Mac using GDB is not complete, though basic debugging works.

    2. Updated the post to use the paths file. Thanks Again !!

  9. Ouch, that's a lot of work just to get Go installed. For me on Linux, all I had to do was run `sudo pacman -S go` (`apt-get install go` for Debian/Ubuntu users) and done, could just open up my Kate text editor and enable the built-in terminal, save the file as go source code and have go syntax highlighting, write the code and save, type go run source-code.go and done.

  10. This comment has been removed by the author.

  11. Thank you very much, I only had to change one c file to work on yosemite in GDB project
    #import machine/setjmp.h to setjmp.h in gdb/darwin-nat.c. before ./configure command

    1. Thanks for sharing that. Can you send me that change so I can publish it :)

  12. Thanks for your shearing , my problem is like this using gdb in liteide :
    10000074^error,msg="-var-create: unable to create variable object"
    some code is ignored when I debugging step by step , could you give me some suggestions?