Go logo


A cross-platform Go IDE with extended support for JavaScript, TypeScript, and databases

Early Access Program

GoLand 2021.2 EAP Build #5 Is Out With a New Button for Updating go.mod and Completion for MongoDB Fields and Operators

GoLand 2021.2 EAP Build #5 is available. You can get this EAP build via the Toolbox App, download it from our website, use a snap package (for Ubuntu), or get it right in GoLand by selecting Automatically check updates for Early Access Program in Preferences / Settings | Appearance & Behavior | System Settings | Updates.  

Download GoLand 2021.2 EAP #5

Before we begin, please note that starting from this EAP, you can join the program only if you have an active JetBrains account. If you have already logged in with your credentials, you can access the EAP builds automatically. If you have not yet logged in, the IDE will redirect you to account.jetbrains.com where you can enter your login and password or create a new JetBrains account. Learn more in this blog post

Load go.mod changes manually

Previously, when you edited go.mod files, GoLand would automatically run go list commands after every modification. This obstructed the editing process, especially in large projects. If you’re in the middle of editing, you wouldn’t want your IDE to flash error messages after every small modification, would you? 

Now you can control this behavior. If you don’t want the IDE to run go list commands automatically, go to Preferences/Settings | Build, Execution, Deployment | Build Tools, where you’ll find the Reload project after changes in the build scripts checkbox. 

By default GoLand will reload the project after any change in the go.mod file. But if you select the External changes option, go list won’t be executed automatically when you edit files inside the IDE. In this case you will see the Load Go modules Changes icon. Finish your editing and click the icon to load the changes.    

If you untick the Reload project after changes in the build scripts checkbox, you will see the Load Go modules Changes icon on all types of changes – both external and internal ones. 

Better handling of different versions of Go

If you use a Go feature from a language version that is newer than the version specified in your go.mod file, you’ll get an error, even if your GOROOT is set to a newer version, and GoLand will tell you what is wrong.

These checks are currently available for several Go features: 

  • Numeric literals
  • Signed integers that are used as shift counts 
  • Overlapping interfaces
  • Slice-to-array-pointer conversions
  • //go:embed statements 

For numeric literals and //go:embed statements, a quick-fix is available.  

Let’s say you want to use a //go:embed statement, and your go.mod file contains the go 1.15 directive. The IDE will inform you that  //go:embed is supported starting from Go 1.16. If you press Alt + Enter (⌥ ↩ on macOS), GoLand will suggest setting the Go version in go.mod to 1.16. 

Warning about unused dependencies 

This feature will help you deal with unused dependencies, which were previously marked red. 

There may be situations where you need to specify a module that isn’t used anywhere in your code (but you still need to have it) in a replace directive. 

Sometimes go.mod files are generated by a script that adds many replace directives, some of which are necessary but some aren’t. Another common case is when you copy replace directives from a tutorial and paste them in your go.mod file.  

Earlier, the IDE wouldn’t download or delete unnecessary modules, and the lines with these unused dependencies would be highlighted in red. The application would work fine, but these red lines have been confusing our users and causing them to look for errors. 

These unused dependencies are now highlighted in grey. If you hover over one of the grey lines, you will see an “Unused dependency” message. You can click on the vertical ellipsis symbol to read a more detailed description. If you still need to download unused modules, press Alt + Enter (⌥ ↩ on macOS) and choose the Download all modules to the module cache option.

This inspection is similar to the go mod why command, except it is executed on the fly.

A better view of attached projects 

Previously, when you attached projects, they would be represented in the Project view as child directories of the existing project. We decided to change that because the actual location of these projects on your computer could be totally different from what was shown in the IDE. 

Now attached projects will appear in the Project view as separate directories.   

Note that this new UI will not be applied to existing multi-projects. If you want to get this UI for your existing multi-project, follow these instructions

Support for new functions in the unsafe package 

In Go 1.17, the unsafe package, which is used to step around type safety in Go, will get two new functions: unsafe.Slice() and unsafe.Add(). Starting from this release, GoLand infers type correctly and doesn’t show false errors when using these new functions. 

In the previous EAP build we provided support for a related change – in Go 1.17 it will be possible to convert a slice into an array pointer without the help of the unsafe package.

To try these new language features, change GOROOT to “Go 1.17beta1” in Preferences/Settings | Go

MongoDB gets Completion for fields and operators 

Code completion now works in the MongoDB console for fields, nested fields, and fields inside aggregation expressions. It also works for query and projection operators, update operators, and aggregations stages.  

There are a few things to consider: 

  • Fields at the top level have a higher priority level than operators, and vice versa for nested fields.
  • Field completion works in all methods except for db.collection.aggregate ([...]).
  • Completion works in string literals as well. 
  • In most cases, completion works when using parameters in scopes. 

Rename refactoring for React hooks

You will no longer need to waste time on refactoring useState values and functions one by one in React hooks – the IDE can now rename both for you! To use this, place the caret on a state value and invoke the Rename refactoring with ⇧F6 / Shift+F6 or by going to Refactor | Rename from the right-click context menu.

GPG signature and other VCS improvements  

You can now sign your commits with a GPG key to secure them. Enable this feature via Preferences/Settings | Version Control | Git. If this is your first time using a GPG key, you’ll need to configure it. With an existing preconfigured GPG key, you just need to select it from the drop-down list. 

For some time GoLand has been using Default Changelist as the name for the node that stores all uncommitted changes. We’ve decided to make the phrasing more precise by using the word “Changes” instead of “Changelists”. This update will be available by default in your new projects. 

Also, the IDE will no longer add changelists automatically for Git operations. So, for example, a cherry-pick won’t trigger a changelist to be created. 

However, if you still prefer automatic creation, you can activate it in Preferences/Settings | Version Control by ticking the Create changelists automatically checkbox.

Better project icon 

Did you know you can customize your project icon? You can do this in the projects list on the Welcome screen. Upload custom icons by right-clicking on any project and selecting Choose project icon from the context menu. We’ve reworked the dialogue window from which you can download your SVG icon to make it neater and more straightforward.   

Collaborative development 

Code With Me recently launched two new servers, one on the US West Coast and another in South Africa. The ping time has been cut by two-thirds as a result, and teams based in those locations can now collaborate in their JetBrains IDEs readily!

That’s it for today! As always, we’d love to hear from you. Leave a comment here, tweet us on Twitter, open an issue in our tracker, or drop us a message in the Gophers Slack #goland channel. Thanks!

image description