My Golang setup

I think I have a pretty nice setup for Go development, so I thought I'd share it and see what other people thought, and what other people do.


1) I track the latest weekly.

Since I develop and publish a few projects, some of which are actually used by real people who aren't my mom, I track the weekly branch of go. It's usually easier to "downgrade" a project from weekly to release, so this way it's easier for me to make sure that a project has good tags for both branches.


2) My $GOROOT is unsullied.

There are absolutely no third-party source files or binaries within my $GOROOT. I make use of $GOPATH to do this, so nothing I install using goinstall gets copied into $GOROOT. I use goinstall to install third-party libraries, exclusively. I have yet to find anything I need that can't be built with either goinstall or gb.


3) export GOPATH = /../gopath:/../devpath

I have two entries in $GOPATH. The first one (and since it's listed first, goinstall puts things here by default) is where third party software goes. The second one, devpath, is where I put packages that I publish for other people to use, and I potentially use in more private projects.

One hiccup I had here is that saying PATH+=$GOPATH/bin no longer works as you might have hoped. And I don't know bash well enough to do something clever here, so I just add both of my GOPATHs to PATH individually.


4) I use gb (http://go-gb.googlecode.com) to build everything. As some of you may know, I am gb's creator, so don't take this as a testimonial for gb, but it's reassuring to know that I eat my own dogfood, isn't it?

Because of how I have things set up, here, it's very easy for me to keep everything building properly with gb. If I update to a new distribution of go (and therefore all the binaries in $GOPATH have gone bad), I could use "goinstall -a -clean" to rebuild everything, but that rebuilds everything. With gb, I can just add the -R flag, and it will go into $GOROOT (everything is up to date there, but it notices the timestamps on the binaries), $GOPATH (now it will rebuild some things, since the GOROOT binaries have been updated) and your local project to make sure everything is up to date.

You could do this with goinstall if you want to make every project you have accessible via $GOPATH. I find this very clunky, as well as restrictive (you might have different versions of the same package - you don't want to build against both).

Another issue here is that if you use makefiles for your project, they do not recognize $GOPATH automatically. You have to add that in yourself. And if you have multiple GOPATH entries, like I do, you have to either list all of them or learn how to use make properly. Neither of those options appeals to me.

Hopefully the next generation of the distribution's build tool will improve upon this issue.


5) I use Sublime Text 2 (http://www.sublimetext.com/blog/articles/sublime-text-2-beta) as my editor. It has a number of features that I think are really slick. Most importantly, though is the directory tree browser on the left of the window. Perhaps it's just me, but I really like to see a directory tree that I can click through to jump to files. Also really nice is the scroll-bar - it has a miniature rendering of your source file that you can drag through to quickly find what you want.

There exist a few sublime plugins written for Go development.

GoSublime (https://github.com/DisposaBoy/GoSublime) has caught on with some people, though I do not use it. GoSublime makes use of gocode (code completion) and assigns the "build" command to run gomake.

GoImport (https://github.com/mkrautz/goimport) is pretty nice - it lets you assign a hot key to add and remove imports. I'm currently giving this a test drive, but I don't know if I'll stick with it.

I have the build command bound to run gb, so I can quickly test whether or not what I just typed compiles.


So that's my setup. What do other people do?
Shared publiclyView activity