Things I Like: GoLand by JetBrains

This one feature makes GoLand an instant buy for me

GoLand by JetBrains is a “Full Stack” (their words) IDE designed for programming in Go as well as the rest of the stack, frontend all the way to database coding. In my own words I would describe it as a “batteries included” professional IDE. All the different components of the IDE are well thought through and designed for a consistent UI and development experience.

GoLand isn’t free. It will set you back $89 the first year for an individual license (as of the time of this writing). While you can recreate a large portion of the features GoLand provides via third party extensions in other IDEs such as Visual Studio Code or Vim, one feature in particular I’ve never in another editor: “Semantic highlighting”.

Semantic Highlighting?

What is semantic highlighting? Isn’t that just code syntax highlighting? To a degree, yes. But semantic highlighting takes it to another level. From the GoLand website

This option extends the standard syntax highlighting with unique colors for each parameter and local variable.

Yes, it highlights variables different colors based off of whether they are passed in parameters, local variables, and more. Let’s take a look at this in action.

Software Versions

Before we get started, this was written with the following notable software versions:

  • Go @ v1.17
  • GoLand @ 2021.2.4

And the following relevant GoLand plugins:

  • Theme Colorful Dracula
  • indent-rainbow.indent-rainbow @ 1.6.1
  • izhangzhihao.rainbow.brackets @ 6.21

Examples of Semantic Highlighting

Let’s look a function I wrote for another article. go function with semantic highlighting example

Starting with the function parameters posts and w are both purple, and are purple when referenced in the body of the function. Contrast that with the first line of the function creating a JSON encoder and assigning it to e, which is a shade of blue.

The beginning of the for loop is where semantic highlighting really starts to shine. We are creating two new variables, i and post, scoped to this loop. This introduces a third variable color to the function. This allows us to scan the code and see what variables and at which scopes they are being used.

Being able to visually understand the scopes of your variables 100% helped me find variable ghosting problems (hello err) and identify a bug in code I had written previously without GoLand. Having this realization during the 30 trial period of GoLand made it an instant subscription for me.