Golang: testing the watersJul 26, 2013 · 3 minute read · Comments
Go has caught my fancy. There, I said it.
The Rubyist in me loves the static duck typing. Loves the promise of never having to navigate ‘murdered by design-patterns’ code (AbstractFactoryFactory anyone?) Loves the near C/C++ speeds (ok, I know Ruby is not the fastest language, but I can always wish, right?) Loves the ability to compile large code bases in seconds. Loves the channels and the freedom they provide in implementing good/crisp CSP.
Sure, there are a few rough edges but nothing sharp enough to stop me from proposing to build the next enterprise application in Go. I mean, if Google betting YouTube and their primary download service on it isn’t precedence enough, I don’t know what can be.
I do not want ThoughtWorks to be late to the party (again.) The time is ripe; the community is still taking shape and extremely malleable (in a good way.) So if a little/lot/hardcore evangelizing is what it takes, I am up for the challenge.
Link to the talk
The talk was never intended to be a hands on session (although it transfigured into one towards the end.) More “daze and amaze.” I think I succeeded on the first part at least.
I wanted to highlight the best bits of Golang from the start. No stringing along for 40 slides whilst pretending to know a lot more than I did.
- Static duck typing
- No explicit inheritance + focus on composing
- Pointers for efficient access
- Built in language support for channels
- Super fast compilation
- Garbage collection
- Gofmt (no more arguments about indentation)
Go will probably make inroads faster into some areas vs others. Main areas of focus are:
- Creating a highly efficient backend service based on RPC / JSON RPC
- Best possible platform for implementing an API end point
- Load balancer / database type applications
- (world is Go’s oyster)
The core members of Go are ensuring that people do not associate Go with not having to test their code. In fact, the best place to learn testing in Go is to browse through the implementation of Go packages (written by the creators of Go themselves.)
- “testing” package makes testing really simple; some may say the approach taken is naive
- GoSpec aims to solve that. Provides a BDD type testing interface for Golang
- Speed of running tests makes the whole process a joy
Deployment couldn’t be easier. Go spits out a statically linked executable, making dependency management a thing of the past. Package up your executable into a RPM/DEB/what-not and throw it up. Couldn’t be simpler.
There are still nascent areas of Go which will require attention from the community to gain traction and get smoothened out. However this shouldn’t stop us from deploying Go as a API backend for a RoR powered AngularJS based single page application. Use the best bits of the various platforms to get going in the fastest manner possible. Throw the rot out as better Go based alternatives become available. :)
Listing the various resources and good to read links (in no particular order):
- CSP (wiki), a must read for understand CSP
- Official homepage
- A web based Go runner
- Official blog roll
- MongoDB Going with Go
- Google Tech Talks YouTube channel
- Seli (written by Diptanu)
- GoSpec, BDD in Go
- GroupCache, a distributed hybrid client/server memcache alternative
- Awesome language metrics by Github for Go
- Brad Fitzpatrik’s Github Profile
- Golang Github Profile
- Docker an awesome LXC management tool (github)
- Flynn, a Docker based OSS Heroku clone
- Revel, emerging defacto Go web framework
- Techempower Benchmarks, comparing Go’s performance to various other web frameworks
- dl.google.com in Go, slides from Brad Fitzpatrik’s talk at oscon about reimplementing dl.google.com in Go
- Go running on a Cubieboard2
- Must watch videos on YouTube