What's New in GoLand

GoLand 2020.2 introduces new features for Go modules, new ways to review and fix problems in your code, and a set of new code inspections. On top of that, you will find new code editing features, such as the long-awaited Add Caret Per Selected Line, experimental support for generics, the ability to share code to the Go Playground from the editor, updates for version control including WSL 2 support for Git on Windows, and more!

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

Go Modules improvements

Set new GOMODCACHE environment variable in the Environment Variables dialog

Starting with Go 1.15, you can change the default location of the modules cache from $GOPATH/pkg/mod to another folder using the new GOMODCACHE environment variable.

To do that, just set GOMODCACHE in Preferences/Settings | Go Modules | Environment. The IDE will recognize the custom location and use it for all subsequent actions with dependencies.

Commenting module dependency in the go.mod file

The Comment With Line Comment (Ctrl+/ on Windows/Linux and ⌘/ on macOS) action is now available for the go.mod file.

GoLand completes a closing brace in go.mod file for replace statement

GoLand now immediately adds a closing brace when you type the opening brace for replace, exclude, and require statements.

Get everything from comments

Navigation from comment to source code

The IDE displays references from comments to related package-level declarations and lets you navigate to them via the Navigate to Declaration or Usages action (⌘B on macOS and Ctrl+B/ on Windows/Linux).

Code inspections

Navigation through warning and errors in the file via the Inspections Widget

The new Inspections Widget shows the number of warnings, errors, and typos in the current file in the upper right-hand corner of the code editor. You can go through them using the arrow icons or the Next Error action (F2).

The widget lets you configure the highlighting level (select from none, errors only, or all problems), change the severity level of inspections, and toggle it to the Compact View so it won’t distract you.

Moving to error from the Problems View and fixing it via Alt+Enter

The Problems tool window displays a list of warnings and errors in the current file, gives you a description of those problems, and lets you fix them immediately using Alt+Enter.

To open the Problems tool window, click on the Inspections Widget or go to View | Tool Window | Problems. Right-click on a problem to move directly to the line of code where the error occurred.

GoLand warns about a possible problem in conversion and suggest to fixing it via Alt+Enter

A new code inspection handles possible problems with string(int) conversions which return the UTF-8 representation of the Unicode code point x instead of the expected decimal string representation of x.

GoLand notifies you about such potential mistakes and provides dedicated quick-fixes.

GoLand warns about an incorrect test name and suggests fixing it via Alt+Enter

GoLand will notify you about common erroneous usages of tests and examples, so you don’t need to call go vet explicitly for that anymore. The IDE also provides quick-fixes in simple cases; for example, it suggests renaming Testme to TestMe.

The Malformed struct tag code inspection alerts the user to a possible problem

The Malformed struct tag code inspection will check that struct tags conform to Go conventions and notify you about potential problems.

GoLand alerts the user about an impossible interface assertion

The Impossible interface type assertion code inspection checks for type assertions v.(T) and corresponding type-switch cases in which the static type V of v is an interface that cannot possibly implement the target interface T.

This occurs when V and T contain methods with the same name but different signatures.

Code editing

Show Context Actions shows possible options to apply

To preview the result of an intention action or quick-fix before you apply it to your code, invoke the Show Context Actions with the Alt+Enter shortcut, select the required intention action or quick-fix, and press ⌥+Space on macOS or Ctrl+Shift+I on Windows and Linux.

The Add Caret Per Selected Line action creates carets at the end of each selected line

The new Add Caret Per Selected Line action creates carets at the end of each selected line and deselects the lines. Invoke it using the shortcut Alt+Shift+G on Windows/Linux or ⌥⇧G on macOS.

The Put arguments on one line intention action splits an expression into separate lines

Configure wrapping for call arguments, function parameters, and composite literal elements in Preferences/Settings | Editor | Code Style | Go | Wrapping and Braces.

Alternatively, you can use the Put arguments on separate lines and Put arguments on one line intention actions using Alt+Enter to split and join elements manually.

Take control of variadic arguments

Inline Variable refactoring unpacks a slice into variadic arguments

The Introduce Variable refactoring (Ctrl+Alt+V on Windows and Linux, or ⌘⌥ V on macOS) can pack some variadic arguments into a new slice variable, while Inline Variable (⌥⌘N on macOS and Ctrl+Alt+N on Linux and Windows), conversely, unpacks a slice into variadic arguments.

The Unpack slice quick-fix in action

In addition, you can now handle issues with unpacked variadic arguments via the Unpack slice quick-fix.

Save projects as templates

Save Project as Template tool window

You can now reuse projects or files by saving them as custom project templates: select Tools | Save Project as Template. The IDE will recreate the project tree with files, folders, and build configurations.

Go Playground

Share in Playground action in the dropdown menu

You can now share and execute code in the Go Playground by double-clicking inside the editor. Just choose Go Tools | Share in Playground in the dropdown menu, or Tools | Go Tools | Share in Playground, or you can press ⌥⇧⌘S on macOS or Ctrl+Alt+Shift+S on Windows/Linux.

This also works for go2 files to play with generics, in which case GoLand will take you to the new https://go2goplay.golang.org/.

Generics a.k.a. type parameters

go2 files are opened in the editor with syntax highlighting and basic reference resolution

The Go Team recently announced a draft design for generics. Please visit the Golang documentation for full details of the concept.

GoLand 2020.2 provides experimental support for generics that you can play with by turning on the Enable experimental support for generics a.k.a. type parameters setting in Settings/Preferences | Go.

This initial support provides syntax highlighting and basic reference resolution, and works in go2 files only.

Under the hood

Sync dependency via Alt+Enter

With vendoring mode enabled, you build your application with only the dependency packages that are stored in the vendor folder in your project.

Now if a project has a vendor folder and you’ve checked the Enable vendoring mode automatically setting in Settings/Preferences | Go | Go Modules, resolve will only use the vendor/ folder and will not consult the modules cache.

GoLand shows go list progress in the progress bar

GoLand runs go list commands sequentially and provides a progress bar with information about the actual numbers of go list commands in the queue.

Version Control

WSL2 support for Git on Windows

WSL 2 support for Git on Windows

GoLand 2020.2 will allow you to use Git from WSL 2, which is natively available in the May update of Windows 10, version 2004. If Git is not installed in Windows, GoLand will automatically look for Git in WSL and use it from there. It will also automatically switch to Git from WSL for projects opened from WSL (via \wsl$ path).

Improved Git action dialogs

Improved Git action dialogs

We’ve redesigned the Git dialogs for actions such as Merge, Pull, and Rebase to make them more consistent and informative. We’ve also made it easier to understand which Git command will be executed, and added the –rebase option to the Pull dialog and the –no-verify option to the Merge dialog.

Start a review with a comment action

Full support for GitHub pull requests

GitHub Pull Requests is fully equipped! Browse, assign, manage, and even merge pull requests, view the timeline and inline comments, submit comments and reviews, and accept changes without leaving GoLand.

Improved presentation of Compare branches results

Improved presentation of Compare branches results

Now, when you are comparing 2 branches in GoLand, you’ll be able to see the commits of the compared branches in one view. The IDE will now open the logs of both branches being compared in the editor instead of in the VCS tool window, where there is not enough space to display all the information.

Databases updates

Separate editor for cell values

Separate editor for cell values

Now if you have a huge value in your cell, it can be viewed or edited in a separate panel. You can also toggle soft wrap mode using the right-hand toolbar. Use all the power of our code editor for your data!

DML preview in the data editor

DML preview in the data editor

Starting with this version, you can review the query that represents your changes in the data editor. There is now a DML button that is active if there are pending changes.

And you will see a dialog with the DML preview. This query is not the exact SQL that will be run to modify your data, because GoLand uses a JDBC driver to update tables, but most of the time it will be the same.

A new UI for boolean values

A new UI for boolean values

There’s now a more user-friendly way to view and edit boolean values. True values are now marked with a bullet point to distinguish them from all the others.

Coding assistance for Google BigQuery dialect

Google BigQuery dialect

We’ve added a new SQL dialect: Google BigQuery. Full support for BigQuery is not here yet, but all things must begin somewhere. GoLand can correctly highlight and provide coding assistance for your queries if you use Google BigQuery.

JavaScript and TypeScript

New smart intentions

New smart intentions (Alt+Enter) will help you perform some actions faster. For example, you can now quickly convert a for loop with a numeric index into a forEach array method. Looking through documentation comments in JavaScript and TypeScript files has also become easier as you can now render them right in the editor, minimizing all distractions.