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.
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.
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.
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.
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.
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.
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.
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.
The Unhandled Error code inspection has gained a whole family of quick-fixes:
if error not nil
check.
defer
and go
statements, produces code similar to Handle error but wraps everything in a
closure.
defer
and go
statements. The quick-fix assigns the call results to blank variables and wraps
everything in a closure.
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.
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 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.
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.
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.
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 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.
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.
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.
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.
You can now access your recent projects by right-clicking on the GoLand icon on the taskbar or on the Start menu in Windows.
Tooltips are now shown one after another to prevent them from overlapping.
You can now select the font variations from the Settings | Editor | Font settings panel.
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.
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.
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, 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.
We've improved the Run/Debug Configuration dialog in several ways:
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.
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.
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.
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.
Last but not least, we've added completion for image names.
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.
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.
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.
We’ve improved the sorting of data:
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.
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.