Some screenshots of gobook.

A Weekend With Go

This weekend I decided to learn the basics of Go and see if there was a way that I could experiment with the language with a quick project, preferably a web app.

I started by reading up the Getting Started guide on the golang.org website and then started using A Tour of Go. About half-way into it, I felt like I had absorbed about all that I could without reading some more complex examples and experimenting.

Installing Go on my laptop was pretty simple. I did have a few issues with getting environmental variables correct to get goinstall to work.

A few google searches lead me to the projects section of the Go Dashboard. From there I started looking at the web frameworks and toolkits. I’ve got a good amount of experience with some of the more do-it-yourself web frameworks like Tornado, so I was looking for the closest thing to that as I could find. The Twister project looked pretty promising.

At this point, I decided to port the logbook project Go as a first project. I picked this one because it is a fairly simple CRUD web application that I wanted to port over to use MySQL from SQLite and integrate bootstrap into it.

This meant finding solutions to two problems: How do I engage MySQL? How should template handling be done? There were a few MySQL client libraries listed on the projects page and a few additional ones mentioned on the mailing list, but the majority were either abandoned, incomplete or unstable. I ended up using GoMySQL, although it has been updated since 5/2011. I’m really hoping that I stumble on or someone recommends a better alternative.

For templating, I saw that there was a mustache library, mustache.go, and went with that. It supports the basics that I’m looking for and I’ve had an itch to use it for a little while now. Although it hasn’t been updated since 4/2011, it seems pretty stable.

Porting the code over was pretty fun. It feels like the standard library set in Go is a bit bare and lacks some of polish that Python has, but all of the basic functionality ported over without a fuss. I had to write a string scanner to parse space/quote separated tags out of a list and deal with MySQL in an ugly way, to name a few.

With all of that said, the project is “done” and all of the functionality ported. Take a look at the gobook project on GitHub and tell me what you think. I’d love to get a quick code review from some people more skilled in Go to learn about how I could be doing some things better.

First impressions: I love it. At my current job I do about 70% Java and 30% c++, mostly building concurrent and distributed backend/platform systems. I usually work on multi-threaded apps and use several different libraries to work (or fake) async functionality: nio, akka, boost thread, libevent, zmq, etc. My last job was 100% Erlang, which has an awesome reputation for massively concurrent development.

What I love about Go is that it feels like it takes the best of what I’ve worked with and distilled it down into a pretty basic set of primitives that cover most of them. I’m not sure if I’ll get to work on Go projects much, but I’d really love to.