Explore the pros and cons of Go for DevOps

Author and Docker engineer Teiva Harsanyi explains the benefits of Golang -- including why he sees it as the future of back-end development -- and how to avoid common pitfalls.

With uses in container systems, API integration and microservices, Go -- sometimes known as Golang -- is an increasingly popular programming language for DevOps and cloud projects.

Go is an open source, strongly typed language that recently ranked in the IEEE's top 10 trending programming languages for 2022. Because Docker and Kubernetes are written in Go -- as are widely used DevOps tools like Terraform and Red Hat OpenShift -- learning Go opens the door to writing customized implementations and plugins and contributing to these open source projects.

"Go itself is becoming more and more the language of the web -- of the cloud and cloud environments," said Teiva Harsanyi, a senior software engineer at Docker and author of the book 100 Go Mistakes and How to Avoid Them. "Most systems today in the context of cloud environments are built in Go."

Harsanyi first began working with Go six years ago, when his team was tasked with migrating a large monolithic application written in C++ that he called "a bit of a mess." When the organization wanted to modernize the project by making it more granular and reliable, Go was a natural choice.

Cover of the book '100 Go Mistakes and How to Avoid Them'Click for more information
about '100 Go Mistakes and
How to Avoid Them.'

In his book, Harsanyi addresses the top mistakes he sees among Go developers and shares advice for getting the most out of the language. The book's 12 chapters walk the reader through common Go errors by category -- such as data types, strings and optimization -- with sample code to illustrate problems and their solutions.

Benefits of the Go programming language

Despite the 100 ways Go developers can go wrong that Harsanyi outlines in the book, he's an advocate for the language. Go, created at Google in 2007, lags in popularity behind more established options like Python and Java, but Harsanyi believes it has several advantages, including stability, simplicity and speed.

According to Harsanyi, the Go landscape hasn't changed much in the three years since he began writing his book -- something he described as one of the language's benefits. Harsanyi said the March 2022 introduction of generics was the first major addition to Go he's seen since he started working with the language.

These relatively infrequent updates, together with Go's expressive nature, make the language stable and readable. Newcomers to modern software development projects are often greeted with hundreds or thousands of lines of existing code. With Go, "it's very easy for someone to arrive on a project and to understand what the code is doing," Harsanyi said. This shallow learning curve is an advantage in fast-paced DevOps environments that require concise and maintainable codebases.

Go's readability largely stems from its simple syntax and standardized design. Because languages such as Python and Java offer multiple ways to accomplish the same task, different programmers can use diverse methods to achieve the same goal. While this wide range of choices is appealing to some, others find it overwhelming -- particularly when the adoption of external libraries and frameworks leads to more complex projects with many dependencies.

I see more and more back-end developers choosing Go in the future.
Teiva HarsanyiAuthor, '100 Go Mistakes and How to Avoid Them'

Go, in contrast, relies heavily on built-in standard libraries, meaning that Go programmers are less likely to need to learn a different approach when joining a new team. Harsanyi gave the example of implementing a new HTTP service. Whereas Python developers can choose among dozens of libraries and frameworks, Go has a standard HTTP service library as part of the core language.

Because Go is statically typed and compiles directly to machine code, Go programs tend to be fast and lightweight, supporting the rapid deployment and high performance needs of DevOps workflows. Harsanyi has worked with a variety of languages -- including Java, Scala, Rust and Python -- and finds Go to be the most efficient for back-end applications.

"I had to get back to Java again last month, and it's an ecosystem that is so much [more] complex to understand," he said. "There are libraries everywhere. ... So I see more and more back-end developers choosing Go in the future."

Gotchas for developers using Go

One of the most significant missteps Harsanyi sees among Go developers involves concurrency: a programming approach intended to improve performance by executing multiple operations at once. This feature is beneficial for DevOps engineers who need to run independent processes and functions simultaneously.

While some languages, such as Rust, require external libraries to write concurrent programs, Go includes concurrency primitives called goroutines and channels as part of the language. However, properly implementing concurrency is still challenging for Go developers. More than half of the concurrency-related bugs found in popular repositories such as Docker and Kubernetes stem from Go-specific problems, according to a 2019 study by researchers from Pennsylvania State University and Purdue University.

In explaining this finding, and throughout the book, Harsanyi said Go's simplicity doesn't eliminate the need to build a deep understanding of how the language works. "Simple doesn't necessarily mean easy," he said. "You can have something simple to write as part of the language, but that doesn't necessarily mean that it's going to be easy to actually implement."

Developers should also consider how different programming languages can work together, rather than viewing them as competitors, Harsanyi said. He sees Go and Rust as particularly complementary for DevOps engineers: Go for implementing quick, efficient and reliable cloud applications, and Rust for low-latency systems where performance is crucial.

"As a back-end engineer, I see the two languages as really the future," Harsanyi said. "I really love the fact that both languages don't seem to conflict with each other."

Download the PDF to read an excerpt from Chapter 3 of 100 Go Mistakes and How to Avoid Them. Chapter 3 ("Data types") covers common errors related to data types, slices, maps and value comparison in Go. The book, released in August 2022, ISBN 9781617299599, is available from Manning.

Next Steps

Important DevOps engineer programming languages to learn

Why you should choose the Go language for microservices development

Dig Deeper on IT operations careers and skills