GoLand 2020.2 EAP Build #6 Out with Support for GOMODCACHE, Faster Resolve for Vendor, and New Code Inspections
You can get this EAP build through the Toolbox App, by downloading it from the website, or by using a snap package (for Ubuntu). Or get it right inside GoLand by selecting “Automatically check updates for Early Access Program” in Preferences / Settings | Appearance & Behavior | System Settings | Updates.
The EAP builds are free to use but expire within 30 days of the build date.
Also, don’t forget that we regularly release nightly builds based on the latest development code. You can use these nightly builds to get access to the latest features without having to wait for the official EAP announcements. These nightly builds are only available via the Toolbox App.
Support for the GOMODCACHE environment variable
Starting with Go 1.15, it is possible to change the default location of the Go Modules cache from $GOPATH/pkg/mod to another folder by using the new GOMODCACHE environment variable.
Even though Go 1.15 is not officially released yet, in GoLand 2020.2 you can already set GOMODCACHE in Preferences/Settings | Go Modules | Environment.
The IDE will recognize the custom location and use it for all subsequent actions with dependencies. The Sync dependencies quick-fix (available via Alt+Enter) will download the dependencies in GOMODCACHE, resolve will lead there, and External Libraries will show dependencies in the new custom location, as well.
Faster resolve for projects with a Vendor folder
With the vendoring mode enabled, you build your application only with the dependency packages that are stored inside your project in the Vendor folder.
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
vendor/ and will not consult the modules cache. An important advantage is that you discover unresolved dependencies faster. For example, if you add an empty
vendor/ folder manually, the IDE will instantly show all unresolved dependencies. You can add them with a handy quick-fix.
GoLand will notify you about commonly mistaken usages of tests and examples, so you don’t need to call go vet explicitly for that anymore. Also, the IDE provides quick-fixes in simple cases; for example, it suggests renaming Testme to TestMe.
Another common pitfall is string(int) conversions, which return the UTF-8 representation of the Unicode code point x – not a decimal string representation of x as one might expect.
GoLand will notify you about such potential mistakes and provide dedicated quick-fixes. For conversions that intend to use the code point, the IDE suggests replacing them with string(rune(x)). Otherwise, it provides a quick-fix to convert an integer to a string using the strconv.Itoa method or its equivalents from the strconv package to return its representation of the value in the desired base.
It is now possible to preview the result of an intention action or quick-fix before you apply it to your code. Invoke the Show Context Action with the Alt+Enter shortcut and select the required intention action or quick-fix. Then press Alt+Space on macOS or Ctrl+Shift+I on Windows and Linux to have a look at the expected changes.