My favourite Golang development tools

Richard Tuin

In the past months I’ve been doing Golang development for several applications. In this post I want to share what I consider the most important items in my Golang toolchain.

Code Quality

It’s probably best to start off with the common Go toolchain for code quality. Most of the editors use these under the hood. This means that code formatting, style checking and error detection is roughly of the same quality in all editors.

Golint

This is here to coach you on code style. It will gently tell you when your code does not adhere to the Go code style conventions mentioned in the Go Wiki.

Example

This code will result in the following warning:

$ golint foo.go
foo.go:6:9: if block ends with a return statement, so drop this else and outdent its block
// foo.go
func isHello(in string) bool {
                if in == "hello" {
                                return true;
                } else {
                                return false;
                }
}

Go

fmt

Format can be used to automatically reformat your code. It will make your code more readable and where possible simplify it. Consider the following before and after example:

// before
if (foo == "foo") {
                _ = "foo"
}
// after
if foo == "foo" {
                _ = "foo"
}

Editor

There are many editors that have Golang support either native or via a plugin. Visual Studio Code (VSCode) and IntelliJ-based editors are my personal favourite because I find them the most complete. Both of these editors are supported on Windows, Linux and Mac.

Visual Studio Code + Go extension

VSCode with the Go extension is full of features for developing applications in Go. Even though its interface is simple, it is full of features. Is has good code completion and automatically reformats your code.

Advantages:

  • Free
  • Automatic code formatting as you type

Disadvantages:

  • Less code-completion compared to PHPStorm + Go plugin
  • Works not so well web-based languages like HTML and JS compared to PHPStorm

PHPStorm + Go plugin

If you’re used to IntelliJ-based editors like PHPStorm then the Go-plugin works quite well. While the code workflow in the JetBrains editors make me more productive, the Go-plugin for them requires a bit more manual labour compared to VSCode + Go.

Advantages:

  • Comprehensive code-completion
  • Advanced code navigation and refactoring tools built-in
  • Best support for web-oriented standards, like HTML and JS

Disadvantages:

  • Doesn’t reformat Go code automatically like VSCode does

Other tools

gcvis

A tool to visualise what the garbage collector is (not) doing. It is easy to use and it helps you identify memory leaks. The information it shows is almost real-time, which is very useful.
You can read more about gcvis on Dave Cheney’s weblog.

Conclusion

Even though there are many tools to aid you in Golang development, these are the ones I use the most. In my next article I’ll give an overview of my favourite Go packages!

Start typing to search