GoLand 2020.1 brings a variety of upgrades for Go Modules support, as well as code-editing features that require little to no interaction from the user and an expanded code completion family.
On top of that, there are new code inspections, quick-fixes, and other improvements, such as the new LightEdit mode, which lets you open a file in the text editor without creating or loading a project, intelligent spelling and grammar checks, and new features for web development and working with databases.
Prefer to learn interactively instead of by reading about it? Complete the Features of GoLand 2020.1 tutorial inside the IDE.
Go 1.13’s environment variables GOPROXY
, GOPRIVATE
, GOSUMDB
, GONOPROXY
, and GONOSUMB
are now supported.
Configure their default values using the Go Modules projects template. Simply click the Browse icon in the Environment field to open the new Environment Variables dialog.
Code completion for go
, module
, require
,
replace
, exclude
keywords, dependencies’ names, and replacements with
local paths is available for go.mod
file.
Rename and Move refactorings are also in business. When you rename or move directories
referenced by replace
statements, GoLand will change the path in the go.mod file accordingly.
Now you can also call up Find Usages via the Project View to explore where the path to a particular directory is used in the go.mod
file.
In GoLand 2020.1 you can fetch missing dependencies and remove unused via Alt-Enter.
Last but not least, the new version will show a notification before you commit if there are replacements with local paths, so that you don’t commit them by accident.
GoLand 2020.1 will suggest if err != nil { ... }
to complete an error-handling pattern. Just type if
inside the expression.
Define struct and interface types faster simply by typing the type
keyword or struct
and interface
.
The Fill Fields action adds spaces after colons when required by the formatting rules. It also adds a comma at the end of the statement in declarations of composite literals.
Now when you are working with maps, code completion moves the cursor to behind the closing bracket after you complete a key type.
For the return type of the function, completion provides suggestions for local variables and zero values that will be appropriate for the corresponding return value type.
Smart Code Completion suggests a pointer to struct initializer.
It also suggests compatible types in assertions and type switch cases first.
In type assertion, it offers the type of the assigned variable.
Finally, it provides a list of suggestions for possible pointers in the expression.
Please welcome Basic Code Completion for comments, which makes writing documentation a lot easier! It suggests names for the current package declarations and parameter names for functions and methods.
Besides that, Basic Code Completion will suggest literals and conversions.
GoLand 2020.1 adds parentheses around return types after the comma when writing a signature of a multi-value return function.
When you paste some text in a string literal, the IDE escapes double-quotes.
To learn more about features that work without you having to do anything, read GoLand Editing Features You Didn’t Know About article.
Go 1.14 has added support for embedding overlapping interfaces, and so have we! When you describe different aspects of a type using overlapping interfaces, GoLand will not report duplicated methods for them as errors.
Vendoring mode is enabled automatically in Go 1.14 if the module root contains a vendor directory. For GoLand 2020.1, we’ve decided to implement similar behavior for Go versions 1.13 and earlier. The IDE will automatically resolve imports to the vendor/ folder if it is present in the module.
To help you more easily distinguish between goroutines during debugging or core dump analysis, we’ve added profiler labels to them.
If you’d like to learn more, read this article: How to Find Goroutines During Debugging.
Now it’s possible to use macros as parameters to run or debug your application. In the Run/Debug Configurations dialog, click + in the Go Tool or Program arguments fields to open the new Macros dialog with the list of available macros to use.
In addition, you can now store the configuration file in the project. Select the Store as project file option at the top of the Run/Debug Configurations dialog.
The .else
Postfix Completion template quickly adds an if
statement to check if the expression is false.
Change a non-formatting call to a formatting one in no time, by pressing Alt+Enter.
The Create variable quick-fix now shows an expected type hint to make it easier to enter the right value.
This new code inspection warns you about invalid calls of pointer methods on non-pointer receivers and offers a quick-fix.
The code inspection Invalid conversions of uintptr to unsafe.Pointer warns you about incorrect uses of uintptr
and unsafe.Pointer
to convert integers to pointers.
The inspection Unmarshal is called with incorrect argument analyzes calls to json.Unmarshal
and similar functions of encoding/json
, encoding/xml
, and
encoding/gob
packages.
The Locks mistakenly passed by value code inspection helps you avoid accidentally copying a value that contains a lock.
We’ve added new templates to help you quickly create groups of declarations. These include
consts
, vars
, types
, and imports
. When you use one of these templates, GoLand will add
braces around the declaration names.
The fori
template inserts the boilerplate code for the classic for-loop.
The Extract Method refactoring keeps the original order of the parent function and method parameters.
The Rename refactoring now detects the renaming of a declaration automatically. This means that when you rename a declaration manually, the IDE will show a gutter icon that will offer to rename all its usages.
Navigate to implementations (Ctrl+Alt+B) and Navigate to Declaration or Usages (Ctrl+B) now show results from the current project first.
Also, the Find Usages (Alt+F7) action now always looks for usages of interface methods by default. To find usages of the current method as before, use Alt+Shift+Ctrl+F7.
The new commit tool window now incorporates the Local Changes and Shelf tabs. This tool window covers all commit-related tasks, like checking diffs, selecting files and chunks to commit, and entering a commit message. Commit is a vertical tool window located on the left side of the screen, which leaves room for the entire editor to show the diff.
The Branches popup has been reworked in several ways:
We have substantially reworked Interactively Rebase from Here. This is a dialog that allows you to edit, combine, and remove your previous commits in order to make your commit history more linear and comprehensible.
To invoke this dialog, go to the Log tab of the Git tool window, select the oldest commit in the series of commits you want to edit, right-click it, and choose Interactively Rebase from Here.
Use new smart intentions and inspections (Alt+Enter) to save yourself some time when coding! For example, you can now quickly convert the existing code to optional chaining and/or nullish coalescing, the syntax introduced in the latest versions of JavaScript and TypeScript.
For JavaScript and TypeScript, the Documentation popup now shows more useful information, including details about the type and visibility of the symbol as well as where that symbol is defined.