GoLand 2021.1 Help

Release notes

Code completion: a varCheckError postfix completion

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

varcheckerror-postfix-completion

Code completion: machine learning for code completion

Machine Learning (ML) is an alternative for the standard ranking mechanism. This code completion applies sorting rules learned from the data that we gathered during EAP. The ML completion might improve suggestions in the auto-completion list.

No source code is collected for machine learning during EAP, only information about interactions with code completion.

To disable this option, open settings by pressing Ctrl+Alt+S and navigate to Editor | General | Code Completion.

machine learning for code completion

Docker: a visual stage separator in multistage Dockerfiles

GoLand displays separator lines in multistage Dockerfiles. These separator lines define boundaries between one stage and another.

#Compile stage FROM golang:1.15.8 AS build-env ADD . /secretproject WORKDIR /secretproject/ RUN go build -o /cmd secretproject/tutorial3/step4/cmd/cmd #Run stage FROM debian:buster EXPOSE 8000 WORKDIR / COPY --from=build-env /cmd / CMD ["/cmd"]
visual stage separator in multistage Dockerfiles

Editor: support of JSON Lines

GoLand now supports the JSON Lines format that is used for working with structured data and logs. The IDE recognizes the following file types: JSONL, JSLINES, LDJSON, and NDJSON.

In this format, files contain several lines, and each new line is a JSON object separated by a newline character.

support of JSON Lines

Editor: maximize tabs in the split view

In the split view, double-click the tab to maximize the editor window. To bring that tab back to its original size, double-click it again.

maximize tabs in the split view

Editor: working with JSON

GoLand suggests new tools for editing JSON and generating Go types from it. To do this, you can use intention actions, code completion, and the Generate Go Type from JSON dialog.

For more information, see Working with JSON.

converting JSON to struct

Editor: the built-in HTML preview

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 the GoLand logo in the widget located in the top right-hand corner of the editor.

the built-in
        HTML preview

Go support: a new inspection for asn1.Unmarshal

Go 1.16 has a new go vet inspection for asn1.Unmarshal. It ensures that the value in which a slice of bytes is unmarshaled is not nil. GoLand has a similar check and also a quick-fix to resolve this problem.

inspection-for-asn1-unmarshal

Go support: Support for //go:embed

Starting with Go 1.16, you can embed files and directories into a Go binary during the build time.

Embedding works for string, []byte, and embed.FS. You can declare these variables at the top level of a package, which means that these variables cannot be contained within function bodies.

The Rename refactoring Shift+F6, the Find Usages action, inspections, and code completion Alt+F7 work with the embed directive.

Support for //go:embed

Import: Support for “goimports -local” import grouping

The built-in formatter can now group imports in the goimports -local style. That is put all imports that begin with the specified string after third-party packages.

“goimports -local” import grouping

Intention actions: generate getters and setters

You can generate all get and set methods for every field in the struct type. Press Alt+Enter on any field name in the struct and select Generate getter and setters.

generate getters and setters

Plugins: support of the Makefile language

The Makefile Language plugin, which provides GNU Make language support, is now bundled by default.

Quick-fixes: type incompatibility inside composite literals

The type incompatibility quick-fix suggests implementing an interface and converting to the expected type inside composite literals.

type incompatibility

Quick-fixes: the Create Type quick-fix

If you use a struct type with fields in your code and that struct is not yet defined, you can apply a quick-fix (Alt+Enter) and generate this struct with all the necessary fields.

the Create Type quick-fix

Quick-fixes: wrap an error handling in a closure

The Unhandled error code inspection alerts you about functions or methods that return errors but the error is not handled properly. This inspection has two 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 the Handle error quick-fix but wraps everything in a closure.

Copy the following snippet to GoLand and try yourself. Alternatively, see the animation.

package main func main() { Open(42) } type Resource int func Open(id int) (Resource, error) { return Resource(id), nil} func (r *Resource) Close() error { return nil }
wrap an error handling in a closure

Refactorings: the rename refactoring for names of Go modules

In go.mod files, you can give a module a new name safely and without running a search and replace it in the project tree.

Click the module name and press Shift+F6. In the Rename dialog, configure the renaming options and press Refactor. Alternatively, click Preview to check all the usages of the module name in the project.

Press Ctrl+Z to revert all the changes.

Rename Go modules names

Running: running applications with elevated privileges

You can run your application with long-living elevated privileges. On the first run, GoLand will ask you whether to keep elevated privileges running or terminate immediately. Later, you can customize this setting in Appearance & Behavior | System Settings | Process Elevation.

For more information about the elevation service, see Running applications with elevated privileges.

Authorization preferences dialog

Running: run targets

You can run your code in another environment such as cloud or a Docker container directly from GoLand. Read more about the feature in Run targets.

Create a run/debug configuration

UI and UX: quick access to recent projects on Windows

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

quick access to recent projects on Windows

UI and UX: better tooltips display

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

UI and UX: improved accessibility

We added more labels to UI elements on the Welcome screen, the Project Structure view, and the VCS log. These elements and gutter icons are now read out correctly when a screen reader is enabled.

UI and UX: typography settings

You can configure typography settings. Open settings by pressing Ctrl+Alt+S and navigate to Editor | Font, and select necessary values for typography.

typography settings

User interface: a quick access menu

The IDE and Project Settings icon has a quick access menu. This menu appears in the top right-hand corner. You can use this menu to switch themes or keymaps, navigate to plugins, or go to the settings.

quick access menu
Last modified: 08 March 2021