mf

What Are the Best Golang IDEs?

Go is a fantastic programming language. It also comes with a comprehensive tool chain. Many developers just use plain text editors with or without plugins to write Go code, but many others prefer to use proper IDEs (integrated development environments). 

In this tutorial, you’ll learn about the current state of Go IDEs and be ready to choose your weapon.

Why Use an IDE?

I was always a big fan of IDEs. Early in my career, I used Microsoft’s Visual Studio for C/C++ development as well C#. I’ve used NetBeans for a short stint of Java development. I’ve used JetBrains’ PyCharm for Python development, and nowadays I use JetBrains’ Gogland for Go development.

I typically work on large-scale software systems that consist of multiple projects with thousands of files. I need a lot of help with large codebases. Here the main reasons why I like IDEs so much:

Integrated Code Organization and Navigation

With a good IDE, you can organize your code hierarchically, view and navigate it with ease, and also quickly search your code. The IDE will do much more than just text search and will let you filter based on language-specific constructs (e.g. show only classes or interfaces with a particular name).

Integrated Testing

Integrated testing is also crucial. I spend most of my development time on tests—either writing them, trying to make them pass, or investigating why tests suddenly failed. A good IDE with integrated testing will let you run tests in a selective way (all, just one project, just failed tests from previous run), will highlight failures, and will let you jump quickly to the right place in the code to fix any problem.

Integrated Debugging 

This is probably the most important feature for me. I love integrated debuggers. I want to be able to add a breakpoint (including conditional breakpoints), view the stack trace, and view the variables at each frame. 

For bonus points (thanks PyCharm), I like to have an interactive console session when a breakpoint hits. The alternatives of printf debugging (requires modifying the code and rebuild) or viewing log files (often not enough granularity or a lot of noise) are much more frustrating and less productive. Even standalone debuggers like gdb don’t come close to the productivity of a good integrated debugger.

Gogland

Gogland is my current Golang IDE. It is a very young product, still in early access preview, but I still consider it the most complete and integrated Go IDE. It is built on the strong foundation of JetBrains, so it’s extremely robust and feature-full.

Code Editor and Assistance

Gogland’s code editor is superb. Here are some of its capabilities:

  • Tabbed interface
  • Smart code completion
  • Inspections and quick fixes
  • Refactorings
  • Quick navigation
  • Quick popups for documentation, definition, usages, structure, etc.
  • Code generation (e.g. implement interface)
  • Detecting recursive calls
  • Showing the type of any expression
  • Highlighting function exit points
  • Parameter hints 

Debugger

The Gogland debugger is excellent. It is built on top of Delve, which is used by other IDEs we cover too. It uses the familiar JetBrains debug configurations to control everything about a debug run such as the executed binary, the environment variables, the working directory, and the command-line arguments. 

You can set breakpoints, conditional breakpoints, and watches. When a breakpoint is hit, you can observe the stack trace and the local variables in each frame. Unfortunately, global variables are not displayed and are often necessary in Go.

I had one issue with the debugger where breakpoints are hit prematurely! Consider the following Go snippet:

Sometimes, if I put a breakpoint on the last line, it would hit, but the value of z would be 0, instead of 4. How can it be? It turns out that the debugger got confused somehow. If I keep stepping through the code, it will jump back to z := x + y, assign 4 to z, and then go again to the last line and properly print 4 to the screen. 

I wasted a couple of hours trying to debug a complicated piece of code, not realizing I wasn’t always getting the correct picture. Eventually, I figured out what was going on and just ignored the fake early triggering of breakpoints.

I’m not sure if it’s a Delve or Gogland problem, but I’m sure they’ll fix it soon. Remember it’s just an early access preview.

Test Runner

The test runner lets you run, stop and restart tests. I was able to use it successfully for running and debugging unit tests, as well as integration tests using both Go’s testing package as well as a BDD testing framework like ginkgo.

Go Tools

Go comes with various tools, and Gogland integrates them right into the IDE. You can invoke any tool from the “Code|Go Tools” menu. The built-in code formatting of Gogland utilizes the standard “go fmt” tool.

Version Control

Gogland inherits the mature source control management system of other JetBrains products. I’ve used primarily the git support, which allows managing of multiple projects, excellent display of branches, multiple change sets, and more. Other source control systems like Mercurial and SVN are supported too, via additional plugins.

Integrated Terminal  

Gogland provides a built-in terminal in case you need to run some commands. It’s nice to stay within the IDE and be able to look at or copy from/to editor panes without switching windows completely.

Extensibility

Gogland comes with tons of built-in capabilities, but it is fully extensible, and many of its built-in features are actually pre-loaded plugins. You can install many useful plugins, and you can develop your own plugins if you wish.

Visual Studio Code

Visual Studio Code is an extensible open-source code editor developed primarily by Microsoft (with lots of contributions from the community). It is based on Electron, which is in turn based on Chromium. Visual Studio Code supports many languages and originally focused on web development. It has strong support for Go development, including integration of all the Go tools and the Delve debugger via a dedicated extension. You’ll need to install some Go packages and tools to get started.

Visual Studio Code also offers built-in git integration, hierarchical folder/file explorer, and a tabbed interface.

The IntelliSense support (autocompletion, showing parameter types and documentation) is great and makes for a very pleasant editing experience. The integrated debugger (also uses Delve under the hood) is very well done and matches Gogland’s debugger.

Visual Studio Code is very responsive and quick. Here is its substantial feature list:

  • Completion Lists (using gocode)
  • Signature Help (using gogetdoc or godef+godoc)
  • Snippets
  • Quick Info (using gogetdoc or godef+godoc)
  • Goto Definition (using gogetdoc or godef+godoc)
  • Find References (using guru)
  • References CodeLens
  • File outline (using go-outline)
  • Workspace symbol search (using go-symbols)
  • Rename (using gorename. Note: For Undo after rename to work in Windows, you need to have diff tool in your path)
  • Build-on-save (using go build and go test)
  • Lint-on-save (using golint or gometalinter)
  • Format (using goreturns or goimports or gofmt)
  • Generate unit tests skeleton (using gotests)
  • Add Imports (using gopkgs)
  • Add/Remove Tags on struct fields (using gomodifytags)
  • Semantic/Syntactic error reporting as you type (using gotype-live)
  • Run Tests under the cursor, in current file, in current package, in the whole workspace (using go test)

LiteIDE

LiteIDE is very unusual. It was the first serious Go IDE, started back in 2011/2012, and it’s still going strong. It’s a C++ Qt application, and it has a custom look and feel. Similar to Gogland and Visual Studio Code, it uses the Go tools and the Delve debugger to provide language services (although it started with the gdb debugger before Delve was ready). 

Overall, it is a full-featured IDE, but it doesn’t feel as polished. As far as I can tell, this is pretty much a one-man effort, which is extraordinary. Here is a breakdown of the LiteIDE features.

Core Features

  • System environment management
  • Configurable build commands
  • Simple and open debug system (supports both gdb and Delve)
  • Kate format for auto-completion and theming
  • Configurable auto-completion with WordApi
  • MIME type based system
  • Plugin support
  • Quick Open

Golang Support

  • Package browser
  • Class view and outline
  • Document browser
  • Gocode support
  • GOPATH API index
  • Code Navigation
  • Find Usages
  • Code Refactor
  • Go playground

Additional support

  • Markdown
  • JSON
  • Golang Present

Wide

Wide is interesting because it is a dedicated Golang web-based IDE. Its focus is on collaborative development, and it’s designed for teams. The developer is Chinese and much of the documentation is in Chinese, so it may not be suitable for everyone. It is definitely not on par with the other IDEs in terms of features and integration.

Go Plugins for Other IDEs

There are many general-purpose IDEs that support many programming languages and have added support for the Go language as well. I’m not a big fan of such environments. I believe that an integrated environment must have deeply integrated language-specific hooks. It is difficult to implement as a simple plugin (although you may argue that this is exactly what VS Code does). 

Some popular development environments that have added Go support are:

  • Eclipse
  • Atom
  • Brackets
  • Komodo
  • Cloud9

Text Editors

Go is a simple language. A lot of people feel very productive just using a text editor, possibly with some additional Go plugins. I don’t consider those really integrated development environments. But it makes sense if you have a lot of years of experience with your text editor, you’ve already customized it to your liking, and you use it for many other tasks. Here is a list of some of the more popular text editors and their Go plugins:

Emacs

With the  following plugins: 

  • go-mode
  • GoFlyMake Flymake-style syntax checking for Go
  • go-errcheck.el Errcheck integration for Emacs

Sublime Text 

With the GoSublime plugin  

Vim and NeoVim 

With a plethora of Go plugins.

  • vim-go
  • Syntastic
  • tagbar
  • vim-compiler-go
  • vim-godef
  • vim-go-extra

Conclusion

Go has come a long way and has a robust ecosystem that includes many options for the development environment. The Delve debugger provides a fantastic interactive debugging experience and is used by most top IDEs. Play around with these IDEs and find the one that suits you the most. 

The right IDE can make working with Go even more fun.

Leave a Comment

Scroll to Top