Why I am spending more time with Golang

Go has been getting a lot of attention, and for plenty of good reasons. I have been looking for a general-purpose, native complied language that is friendly towards Continuous Delivery/DevOps movements, and Go seems to fit the bill well. I appreciate the philosophy of simplicity, pragmatism and effectiveness.

As a simple test, I wrote a simple microservice that returns the current system time with JSON over HTTP.  Here is the source code:

That’s all. The end product is a native, compiled binary that includes a Web server, JSON serialization components, and everything else to make it happen. The size of the compiled binary is 7.5 megabytes on Linux, 7.4 on Mac OS X. In terms of dependencies, it looks not that different than a ‘Hello, World’ would in C, save for the pthread dependency:

That’s it. Again – that’s it.

Golang delivers language-level and binary packaging simplicity. In relation to source code and configuration, there isn’t much fluff whatsoever. Compare and contrast that with a typical Java-based implementation, for instance. The binary itself is similarly compact. At 7.5 MB, that is virtually nothing when, once again, compared to a typical Java based service implementation – a JRE, Tomcat, Spring framework and all the other minimally required usual suspects. Deployment with Golang is simple and faster.

Of course, there are some rough edges to Golang, like anything else under the Sun. For instance, see this great write up from UpGuard, particularly the part describing some idiosyncratic behavioral patterns with non-range limited slices (https://play.golang.org/p/nk1dMk2DV-).

Overall, color me a believer. More to come.

P.S. You are welcome to download the source code above here: https://github.com/ibondare/gotime

Or if you have Go and Git installed:

Post navigation