GoLand 2020.2 Help

Release notes for GoLand 2020.2

Actions: the new Add Caret Per Selected Line action

The Add Caret Per Selected Line action creates carets at the end of each selected line. To invoke the action, press Alt+Shift+G.

the new Add Caret Per Selected Line action

Code formatting: wrapping for call arguments, function parameters, and composite literal elements

To configure wrapping for call arguments, function parameters, and composite literal elements, open settings by pressing Ctrl+Alt+S and navigate to Editor | Code Style | Go | Wrapping and Braces.

Code formatting: wrapping for call arguments, function parameters, and composite literal elements

Code formatting: intention actions for wrapping arguments

To wrap arguments in the function signature, place the caret before the opening bracket, call the intention action by pressing Alt+Enter, and select Put arguments on separate lines. To revert this action, press Alt+Enter and select Put arguments on one line.

Intention actions for wrapping arguments

Generics: the experimental support of type parameters

Experimental feature based on the proposed draft design at go.googlesource.com.

Type inference is not supported yet, you might see red code when passing parameters to a function with type parameters.

Enable the experimental support of type parameters

Go Modules: the focus does not switch aggressively between tool windows

When you get errors from running go list -m all, the IDE does not switch the focus from the active tool window to the Run tab.

Go Modules: notification when you edit go.sum

The go.sum file contains the expected cryptographic checksums of the content of specific module versions. If you want to change go.sum, modify the go.mod file.

GoLand displays a notification when you edit go.sum.

Notification when you edit go.sum

Go modules: Support for the GOMODCACHE environment variable

The default storage place for the Go modules cache is $GOPATH/pkg/mod. By using the GOMODCACHE environment variable, you can change the default location to a different one (for example, $WORK/modcache).

Usage of the GOMODCACHE environment variable

Go modules: dependencies in the vendor folder resolve faster

If you have a vendor directory in your project, Go builds your application only with the dependency packages that are inside this directory. Since GoLand 2020.2, GoLand ignores the Go modules cache and uses the vendor directory only. This feature helps to discover unresolved dependencies faster.

For example, if you add an empty vendor directory manually, GoLand will instantly show all the unresolved dependencies that you can add with a quick-fix.

Go Dependencies In The Vendor Folder Resolve Faster

Go modules: autocompletion of parentheses in go.mod

For replace, exclude, and require statements, GoLand adds a closing parenthesis immediately after the opening parenthesis.

Go modules: go list commands run sequentially with a progress bar

In GoLand 2020.2, go list commands run sequentially. You can see the progress bar with the actual numbers of go list commands in the queue.

Inspections: notification about the violation of Go conventions for struct tags

The Malformed struct tag code inspection reports struct tags that do not conform to Go conventions.

For example, this inspection reports fields that repeat values in JSON tags.

Inspections: notification about the violation of Go conventions for struct tags

Inspections: the widget for inspections

To navigate between detected problems, you can use the Inspections widget. The Inspections widget shows the number of warnings, errors, and typos in the current file. You can go through them using the arrow icons or by pressing F2.

By using the Inspections widget, you can configure the highlighting level (None, Errors Only, or All Problems), change the severity level of inspections, and toggle the Compact View.

Results of instant analysis

Inspections: malformed names of tests, benchmarks, and examples

GoLand reports malformed names of tests, benchmarks, and examples, so you do not need to call go vet explicitly. In some cases, GoLand suggests quick-fixes. For example, to rename the Testcalculate function to TestCalculate due to Go conventions for names.

Go Malformed Names Of Tests Benchmarks And Examples

Inspections: string(int) conversions

The string(int) conversion returns the UTF-8 representation of the Unicode code point and not its decimal string representation. For conversions that intend to use the code point, GoLand suggests replacing such conversions with string(rune(x)). Alternatively, you can convert an integer to a string by using the strconv.Itoa method or its equivalents from the strconv package.

Inspection for the string int conversion

Intention actions: preview of intention actions

For some intention actions, you can open a preview by pressing Ctrl+Shift+I.

Inject a language with the intention action

If you click the reference in comments, you can navigate to related package-level declarations in the same package. Also, you can use the Navigate to Declaration and Usage action (Ctrl+B) for such references.

Names of methods, functions, and structs in comments are highlighted.

GoLand highlights references to exported symbols only. Words are resolved to package-level declarations in the same package. Two words separated with a dot are treated either as Type.Method or as package.SymbolName.

GoLand highlights references only if the name is unique to reduce the number of false positives.

Navigation: highlight references from comments to related package-level declarations

The Find Usages action searches for embedded structs and interfaces.

Plugins: the Swagger plugin

GoLand supports the Swagger plugin. By using the Swagger plugin, you can edit Swagger and Open API specification files.

Note that you need a local JAR with swagger-codegen or an HTTP link to swagger-codegen on Maven Central.

Project: the Save Project as Template action

You can save a project as a template. Later, you can create projects that are based on the saved project. For example, you can use this template for the projects that are nearly identical to the template project.

Creating a project from a custom template

Quick-fixes: the Unpack slice quick-fix

The Unpack slice quick-fix converts a slice to a variadic variable.

Quick-fixes: the Unpack slice quick-fix

Refactorings: refactorings to work with variadic arguments

Use the Introduce Variable refactoring (Ctrl+Alt+V) to extract variadic arguments into a new slice variable.

To reverse the Introduce Variable refactoring, use the Inline refactoring (Ctrl+Alt+N).

Refactorings to work with variadic arguments

Tool windows: the Problems tool window and the Inspections Widget are introduced

The Problems tool window displays a list of warnings and errors in the current file. You can fix these issue by using an intention action. You can call the intention action by pressing Alt+Enter. Alternatively, right-click the issue and select Show Quick Fixes.

the Problems tool window and the Inspections Widget

VCS: Merge, Pull, and Rebase dialogs

GoLand now includes new Merge, Pull, and Rebase dialogs.

the Pull dialog

WSL support: WSL2 support for Git on Windows

GoLand supports Git from the Windows Subsystem for Linux 2 (WSL2), which is available in Windows 10 version 2004.

If Git is not installed on Windows, GoLand searches for Git in WSL and use it from there. Also, GoLand automatically switches to Git from WSL for projects that are opened when you use the \wsl$ path.

WSL2 support for Git on Windows
Last modified: 14 August 2020