Gogland EAP 16: File Watcher, Tons of New Inspections, Smarter Navigate to Test, and More
Hooray, it’s time to check for updates! Please welcome Gogland EAP 16, a fresh EAP build with lots of improvements. Read on to learn more.
File Watchers and Macros
First of all, we’ve deprecated the On Save actions and replaced them with the File Watchers plugin. The new functionality supports not only gofmt and goimports, but also gometalinter and any custom user commands. The commands configured with File Watchers are applied not only on manual save but even when you switch your focus from the editor.
If you have previously configured On Save actions, the IDE will prompt you to install the plugin and configure everything automatically. If you want to set it up from scratch yourself, install the plugin, then go to Settings | Tools | File Watchers, and click the Plus button to add go fmt, goimports or gometalinter.
To make the File Watchers plugin work with Go tools, we’ve supported the $GOROOT$, $GOPATH$, $GoFileImportPath$, $GoExecPath$, and $GoBinDirs$ macros. Now you can use these not only with File Watchers but also with External Tools and Run Configurations.
File and Code Templates
The Generate New action now uses Settings | Editor | File and Code Templates | Code for generating tests, benchmarks, and examples. Now you can customize these templates.
Navigate to Test
The Navigate to Test action (available via Ctrl+Shift+T or Cmd+Shift+T on macOS) now integrates gotests. It is able not only to navigate between a test and its test subject, but also to generate tests for a package, file, and function.
Go Generate
The Go Generate action, earlier available as an inspection, can now be called on a folder. You can now do it either by calling the action after selecting a folder in the Project tool window, or by using the gutter icon next to a go:generate statement in the editor:
Inspections
1. The IDE now alerts you if you try to index a map or a slice which is not initialized yet (so you can get a panic in runtime):
2. If you have a type that is unused and is either unexported or resides in a main package or tests, the IDE offers to safely delete it along with its functions:
3. The IDE alerts you if you specify an explicit type when declaring a variable or a constant where the compiler can infer it automatically. In this case, the IDE offers quick-fix to remove the type.
4. The inspections that rely on type inference have become more accurate for pointer types (and now produce far fewer false positives):
5. The intention action that initializes structs (added earlier) has been updated and now supports arrays:
SQL
For those of you who use database/sql, jmoiron-sqlx or markbates/pop in your code, you may have noticed that the IDE now offers coding assistance for SQL statements.
The coding assistance includes syntax highlighting, basic code completion, and validation with regard to the selected dialect.
Go Plugin
Last but not least, there’s an important update for users of the Go plugin. Now the plugin will be available only for IntelliJ IDEA Ultimate users. Now, if you’re using an IntelliJ-based IDE that is not IntelliJ IDEA Ultimate, to work with Go you’ll have to switch to either Gogland or IntelliJ IDEA Ultimate.
We are making this change because we want the Go plugin to follow the pattern in which we offer plugins for Python, PHP, Ruby, etc. For example, PHP support is offered as a standalone IDE (PhpStorm) and as a plugin for IntelliJ IDEA. Ruby support is offered in RubyMine and as a plugin for IntelliJ IDEA. Similarly, Go support will be offered in Gogland and as a plugin for IntelliJ IDEA. We apologize for any inconvenience.
That’s it for now. Hope you’ll enjoy the update and find it useful. As always, bug reports, feature requests and simply general feedback are very much appreciated in our issue tracker.
Happy developing!