What's New in GoLand

GoLand 2021.1 allows you to build and run your program remotely via Docker, SSH, and WSL 2, use newly supported features from Go 1.16, including //go:embed, quickly generate code from JSON, and handle errors with ease using new quick-fixes.

GoLand is more than just Go IDE — on top of features for working with Go code, you will get new features for JavaScript, TypeScript, and databases.

Prefer to learn interactively instead of reading? Complete the What's New in GoLand 2021.1 tutorial inside the IDE on the Welcome screen.

Run Targets

Configuring created targets in the 'Run Configuration' window

In GoLand 2021.1 you can develop on your machine, with all the source code available to you locally, and target remote computers to run your code. Currently, the IDE supports Docker, SSH, and WSL 2 (Windows Subsystem for Linux).

In settings, choose Run | Manage Targets…, click the Add icon (+), and select the targets you want to work with. After completing the configuration, you need to specify the Run Configuration from Run | Edit Configurations… and select the target you want to work with.

Go 1.16

Adding a folder to embed directive

Support for //go:embed

Starting with Go 1.16, you’ll be able to embed files and directories into a Go binary at build time.

Embedding works on a few types of variables: string, []byte, and embed.FS. You need to declare these variables at the top level of your package. Finally, you need to add the //go:embed directive for embedding to work.

GoLand provides code highlighting, navigation from references inside the embed directive to files and folders in your project, Rename refactoring, Find Usages, code completion, and a few code inspections. For example, GoLand will notify you if you try to embed files into a variable of the wrong type.

Replacing 'Fatal' method with 'Error' method via quick-fix

Detecting incorrect usages of (t/b).Fatal

GoLand warns you about invalid calls to the testing.T method Fatal within a goroutine created during the test.

The dedicated quick-fix will rewrite the code calling t.Fatal (or a similar method) so that it signals the test failure using t.Error and exits the goroutine early using a return statement.

The IDE shows a warning and provide an appropriate quick-fix to resolve it

Detecting incorrect usages of asn1.Unmarshal

In Go 1.16, go vet detects incorrect usages of asn1.Unmarshal, making sure that the value in which a slice of bytes is unmarshaled is not nil.

GoLand 2021.1 provides a similar check with a quick-fix to resolve this problem.

Working with JSON

Pasting JSON data in the editor by copy-pasting

Generate a struct with fields and tags from JSON in no time by simply copy-pasting JSON data into the editor.

If you want to adjust the JSON before generating a struct, press Alt+Enter to invoke the Generate type from JSON intention. GoLand will open the Generate Go type from JSON window with the copied JSON. You can tune it as you wish in the window, then press the Generate button and your struct will be ready to go. Of course, it’s also possible to paste JSON into the window manually.

Additionally, it’s possible to convert JSON inside an already existing empty struct. To do so, just click this empty struct and call the Generate struct fields from JSON intention action by pressing Alt+Enter or by using the Generate menu.

Besides that, GoLand will notify you if you use invalid JSON code in the Generate Go type from JSON window.

Generating a struct from JSON data via the 'Generate Go type from JSON' window

It’s now much easier to create JSON and XML tags for all the exported fields in the struct.

When you use Alt+Enter to invoke Add key to tags on the struct or on any field in the struct, GoLand adds a tag to all fields in the struct with field names. If you want to change the style of the field name for all tags, press Alt+Enter again on any key and choose Change field name style in tags. The supported styles are fieldName, FieldName, field-name, and field_name.

You can update all tag values at once with the Update key value in tags intention action. Press Alt+Enter on any tag value in your struct and GoLand will add carets at the end of the tag values in every field.

Additionally, the IDE provides a completion for well-known tokens inside tag values provided by SDK for JSON, XML, and ASN.1 code.

A JSON file in a new supported style

Last but not least, GoLand 2021.1 supports the newline-delimited JSON Lines at used for working with structured data and logs. The IDE will recognize .jsonl, .jslines, .ldjson, and .ndjson file types.

In this format, files contain several lines, and each new line is a JSON object separated by a newline character. Commas are required at neither the beginning nor end of lines, and there is no need to enclose the entirety of the file contents in square or curly braces.

Handle errors with ease

The 'Unhandled Error' code inspection in action with the 'Wrap error handling in a closure' quick-fix

The Unhandled Error code inspection has gained a whole family of quick-fixes:

  • The Handle error quick-fix assigns call results to variables and generates an if error not nil check.
  • The Wrap error handling in a closure quick-fix, which is available for defer and go statements, produces code similar to Handle error but wraps everything in a closure.
  • We’ve extended the Ignore explicitly application area to include defer and go statements. The quick-fix assigns the call results to blank variables and wraps everything in a closure.

More quick-fixes

Converting byte to string via the new quick-fix

Quick-fix for type incompatibility inside composite literals

We’ve expanded the application area of the quick-fix that addresses type incompatibility. It now also suggests implementing an interface and converting to the expected type inside composite literals.

Creating type with all necessary fields via the new quick-fix

Create Type quick-fix generates missing fields

The Create Type quick-fix offers not only to create a type when GoLand notices you are using one that has not yet been defined, but also it will create fields for you as well.

Generating getters and setter from the struct via the 'Select Fields' window

Generate all getters and setters at once

Generating get and set methods for each field in huge structs can be rather tedious. You can now generate getters and setters for the whole struct all at once.

Press Alt+Enter on any field name in the struct, then choose Generate getter and setters from the drop-down menu. GoLand will open the Select Fields window, where you can generate get and set methods for all the fields or just for the fields you need.


Extracting a type from the existing structure

The Extract Type refactoring

The Extract Type refactoring lets you extract a type from an existing one or convert an anonymous structure type to a named type. Press Ctrl+Alt+Shift+T to invoke it.

Go Modules

Renaming a module name via 'Rename' refactoring

Rename refactoring for the go.mod file

Sometimes you need to rename a module once you have sufficiently experimented with the project and done all your initial work. We’ve added the Rename refactoring to the go.mod file. It allows you to rename the module with a new name safely, without needing to do a search and replace in the project tree to replace the old module name.

Invoke the Rename refactoring on the module name with Shift+F6. GoLand will open the Rename window, where you can change the current name, choose whether to change it in comments and strings, and open a preview of the refactoring. From the Refactoring Preview tab, you can navigate to all usages of this module name. You can use undo to quickly revert all changes implemented using the refactoring.

Postfix Completion

The new Postfix completion in action

New varCheckError Postfix Completion

Type .varCheckError after an identifier that returns an error, and the IDE will automatically add default variable names and return the error from the function.


The 'Import' settings

The built-in formatter can now group imports in the same way goimports -local does.

To enable this support, head over to Settings | Editor | Code Style | Go | Imports and enable import grouping. Then you can specify which imports should be grouped into separate blocks.

Run & Debug

The settings of 'Process Elevation'

GoLand 2021.1 allows you to run an extended sudo session. On the first run, GoLand will ask whether you want to keep sudo running or terminate it immediately. If you would like to change your response, go to Settings | Appearance & Behavior | System Settings | Process Elevation.

Please note that by enabling this option you grant GoLand and all third-party plugins access to your system.

Code Completion

The results of code completion with turned on Machine Learning-Assisted Completion

We’ve enabled Machine Learning-Assisted Completion. This change introduces the early stages of code completion based on machine learning (ML), which is an alternative to the standard ranking mechanism.

Tick Mark position changes in the completion popup in Settings | Editor | General | Code Completion to mark options reranked by ML completion with up/down arrow icons in the completion list.

UI improvements

Changing the theme of IDE using the new quick access menu

Quick Access Menu

The Configuration widget, which was previously available in the bottom left-hand corner of the IDE, has been replaced with a quick access menu. This new menu appears in the top right-hand corner. Press the gear icon to switch themes or keymaps, navigate to plugins, or go to the settings.

Quick access to recent projects on Windows

Quick access to recent projects on Windows via the 'Start' menu

You can now access your recent projects by right-clicking on the GoLand icon on the taskbar or on the Start menu in Windows.

New tooltips display

Better tooltips display

Tooltips are now shown one after another to prevent them from overlapping.

The 'Typography' settings

Font variations

You can now select the font variations from the Settings | Editor | Font settings panel.

Other changes

A new built-in browser preview in action

Built-in HTML preview

We’ve added a new built-in browser preview that helps you quickly preview HTML files. Any changes you make to HTML files in the IDE, as well as in the linked CSS and JavaScript files, will be immediately saved, and the preview will update on the fly.

To open the preview, click on the GoLand logo in the widget located in the top right-hand corner of the editor.

Changing a size of the tab in the editor

Maximize editor tabs in the split view

Need more space when working on multiple files simultaneously in a split editor? Double-click the tab you’re working with to maximize the editor window for it. To bring that tab back to its original size, simply double-click it again.

Installed 'Makefile Language' plugin on the 'Plugins' page in the IDE

Makefile Language plugin works by default

The Makefile Language plugin (previously 3rd-party), which provides GNU Make language support, is now bundled by default. Starting with GoLand 2021.1, you will get syntax highlighting, quick documentation, Find Usages for targets, and some navigation and code completion actions for Makefile right out of the box!

Code With Me

'Code With Me' in action

Code With Me, a new JetBrains service for collaborative development and pair programming, is now bundled with GoLand.

Set the needed level of access to your project and share the link with your guests. Your peers do not even need to have their own IDEs installed to collaborate with you. Embedded audio and video calls, along with chat messaging, will help teams discuss the code, share their knowledge, and cooperate more efficiently.

For businesses that require extra-security, Code With Me on-premises can be installed and securely run on a company’s own private network.

To learn more about the availability of Code With Me with your current JetBrains license, check out the pricing page.


Code completion in the 'Run Options' field

Improved Run/Debug Configurations

We've improved the Run/Debug Configuration dialog in several ways:

  • To add all the necessary build options, click Modify options; to add run options, click Modify. The IDE now validates each option to make sure it is compatible.
  • For Docker-compose, we support all the existing options, including the one for declaring Environmental variables files (.env).
  • For Dockerfile, you don’t have to remember all the run commands because code completion works in the Run Options field.
  • For Docker Image, you can use code completion to enter the name of the image in the Image ID or name field.
The IDE builds the image using BuildKit

BuildKit support

We’ve added experimental support for BuildKit, which makes building projects much faster. You can activate this option in Run/Debug Configurations by clicking Modify options and selecting Enable BuildKit (experimental).

Simply click the hammer icon next to the stage name, and the IDE will build the image using BuildKit. If you add the Run section in Run/Debug Configurations, the icon will change. When you click it, you will not only build an image but also run a container.

Folding stages in the editor

UI enhancements in multi-stage Dockerfiles

If you use multiple FROM statements in your Dockerfile, each FROM instruction starts a new stage. In GoLand 2021.1, you can now fold stages and see a distinct separator line between them.

Stop Docker via the dedicated button in the Services tool window

Cancel Docker run

If you decide to stop a running Dockerfile, you can easily do so in the Services tool window. Select the running item, call up the context menu, and click Stop Deploy.

Code completion in the 'Bind Mounts' window

Environment variables and macros for Docker mounts

When using bind mounts, you can now enter a path to a directory on the host machine faster. The completion mechanism allows you to select macros and environmental variables in the Bind mount option in Run/Debug Configurations.

Code completion for images in the Dockerfile

Images completion in Dockerfiles

Last but not least, we've added completion for image names.

Web development changes

A tooltip with MDN documentation in the editor

Bundled MDN documentation

MDN documentation is now bundled with GoLand. This will help prevent connectivity issues with the MDN website and make in-editor documentation in your HTML, CSS, and JavaScript files display more quickly. In-editor documentation will also become more informative – for example, you’ll now see details about supported browser versions for JavaScript APIs.

Stylelint in action with corresponding quick-fix

Improved support for Stylelint

Inspecting your CSS code with Stylelint is now easier. You can now fix problems with this popular linter in just a few clicks. Hover over a problem in your file or place the caret on it and press Alt+Enter, then select Stylelint: Fix current file.

Additionally, you can now specify a path to the configuration file under the corresponding field in Settings | Languages & Frameworks | Style Sheets | Stylelint.

The documentation popup for a selector

Selector specificity for CSS

When working with style sheets, you can now check the specificity of your selectors – just hover over a selector that you want to check. Alternatively, focus on a selector and press Ctrl+Q to see this information in the Documentation popup.

Work with databases

A new 'ORDER BY' field in a table

Better sorting

We’ve improved the sorting of data:

  • A new ORDER BY field works similar to the WHERE field (which was called Filter before): enter a working clause to have it applied to the query of the grid.
  • The sorting is not ‘stacked’ by default. This means that if you click on a column name to sort data by, the sorting based on other columns will be cleared. If you would prefer to use stacked sorting, click a column name while holding the Alt key.
  • If you want to use sorting on the client side (GoLand will not rerun the query nor sort the data within the current page), uncheck Sort via ORDER BY.
  • It’s also possible to open tables with predefined sorting based on the numeric primary key.
'Select first N rows from a table' in the editor

Context live templates

This is our solution for anyone wanting to generate simple statements straight from the database explorer. General live templates cover many cases where you need to write a simple query quickly. But we also understand that sometimes, when you are in the context of the database explorer and you are already focusing on the object you need, there is a better way to get a simple query using that object.

Select first N rows from a table looks like a general template (and can be used as such). Since this particular syntax cannot be used in all databases, the corresponding dialects are set for the template. The major difference that makes this template applicable in the database explorer is the special expression dbObjectName, which is used for the $table$ variable.

Adding grant to object via the new window

UI for grants

We’ve added a UI for editing grants when modifying objects.

The Modify user window, which you can invoke on a user in the database explorer with Ctrl+F6, now has a UI for adding grants to objects.

This is available for PostgreSQL, Redshift, Greenplum, MySQL, MariaDB, DB2, SQL Server, and Sybase.