Why DevOps Engineers Should Know Go
Golang came onto the tech scene by the end of 2009 and slowly established it’s position as one of the major players in the DevOps world. Today, let’s delve into why investing your time into learning Golang (Go) will pay off tenfold.
Most of the DevOps tools are written in Golang
The very first, never released to the public, version of Docker was written in Python – but, the initial release was made using one of the initial (!) versions of Go. Kubernetes – all done in Go. Hashicorp’s Terraform and Vault – all done in Go. Prometheus, Helm, Loki, Grafana – you know it – Go!
Go is insanely powerful and works super well on the full variety of platforms – in Docker’s case, it was Linux, with which Go binds perfectly. By default, it helps you to divide your code into small packages, that are extremely easy to re-implement into new software.
If you don’t want to use Kubernetes or something similar to load-balance your app, you can write your own load balancer using channels and it will be stable enough to use in a production environment. The whole load balancer can be done in less than 40 lines of code, without using ANY third-party packages!
Go might be your next choice for scripting
Following an amazing talk by Ignat Korchagin @ GopherCon UK 2019 about using Go as a scripting language in Linux, you can see how you can use Go as your next big thing for scripting. Introducing type safety, simple syntax and great speed, you can do a lot of things you’d normally do with Bash scripts but make it nice, understandable and testable by anyone.
Cli? Let’s Go!
Always wanted to write a Command Line Interface? Maybe you want to fetch data from Wiki without leaving your glorious terminal (I know I do), Go is a great choice to write a CLI in – either by using a standard library or one of the great packages like Urfave’s CLI or Spf13’s Cobra – both are true & tested in battle by many!
Want extra colour? Use aurora for those ANSI colours in your terminal! Need to do any REST calls from within your app? Everything is already built-in and waits to be used!
Go by default encourages their developers to write and maintain the documentation for their packages. Starting with godoc – which is an inbuilt mechanism that generates documentation from your code in either HTML or plain text – and ending on the way the documentation itself is written – take net/http package documentation.
No more need for googling for that one code snippet or spending countless hours on YouTube and watching tutorials. The language-level docs are written in a way where every word matters. It takes a second to get accustomed to it, but after a while, you don’t spend hours reading pages of documentation (looking at you, Java!). Instead, you get no-nonsense, straight to the point documents explaining how everything works.
Does basically everything
Http server? Check.
Generating images? Check.
Race Detection? Check.
Going low-level and incorporating C? Check.
Web Assembly? Check!
And that’s all done with Go native libraries. Option grows as we go (no pun intended!) – from Chrome drivers to in-terminal games, finishing on full integration with gRPC. Heck, you can transpile your Go code to do Front-End (if you’re brave enough!).
Also – microcontrollers? Check!
Written by legends
Golang began its life as a brainchild of Robert Griesemer, Rob Pike and Ken Thompson. Just to give you a quick history lesson:
* Mr Pike was part of a team that developed the Unix system, was co-developer for Bilt graphical terminal and wrote the first window system for Unix in 1981 AND created “sam” and “acme” text editors;
* Mr Thompson designed and implemented the original Unix system, invented the B programming language – which is the direct predecessor to the C programming language – and was working with Mr Pike on Plan 9 from Bell Labs.
As you can see, the power of Go comes with literally years (one might say decades) of experience from very low-level tools. That might be scary, but it’s not. All three wanted to create a language that will have all the power – but no problems (such as very hard-to-understand syntax) – of C. And you can feel it writing Go.
And last, but not least – Go is fun. The syntax, the ease of concurrency, garbage collector, hacking the language for your own purposes, and so much more.
Although Go has no in-built library for user interfaces, thanks to magicians like Elias Naur and his absolutely, insanely amazing Gio we’re even closer to getting a full-blown UI engine – just wait!
Ok, I’m sold. Sign me up! How can I start?
Best way? Go to golang.org and get a binary specific for your operating system. Or, if you want to probe and see if you like it – check out the May 2020 DevOps Playground and A Tour of Go. The Playground will allow you to check everything that Go has to offer, whereas A Tour of Go will lead you into the nitty-gritty of the language in the safe environment of your browser!
Well, all that’s left to say is, Go!