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!

About Andrey Cheptsov

Part-time dreamer. JVM/JavaScript geek. IntelliJIDEA Marketing Manager at JetBrains.
This entry was posted in EAP, New Features. Bookmark the permalink.

23 Responses to Gogland EAP 16: File Watcher, Tons of New Inspections, Smarter Navigate to Test, and More

  1. Michael Whatcott says:

    Great stuff! This just keeps getting better and better. :)

    What’s the status of refactorings such as “Extract Method” (which currently only extracts a standalone function) and “Inline Function/Method”? Can’t wait to be able to use those…

  2. Shaunn Barron says:

    Syntax highlighting and code completion don’t seem to work with markbates/pop directly. For instance, this code doesn’t work,

    func nukeRecipients(tx *pop.Connection) error {
    return tx.RawQuery("DELETE FROM failure_recipients").Exec()
    }

    However, if I drop down to the sqlx level, it does:

    func nukeRecipients(tx *pop.Connection) error {
    _, err := tx.TX.Exec("DELETE FROM failure_recipients")
    return err
    }

  3. Alexander says:

    Вопрос, насколько я помню File Watcher нужно было настраивать для каждого проекта отдельно. Появилась ли возможность сделать это глобально в Gogland?

  4. Gora Tensla says:

    Is there a way to get gometalinter output represented as wiggly underlines directly under the line the warning/error happened instead of as text in an output panel?

  5. Zach says:

    I’m sad On Save was removed

  6. Bertram Truong says:

    It’s great that the “On Save” has been replaced with the “File Watcher”. It’s much more responsive now (I was originally having issues sometimes with “On Save” not triggering).

    However, that’s introduced a new issue. I have a File Watcher rule that runs goimports against the saved file and writes it back to disk. But, as I’m typing, and the auto-save kicks in, I’ll get the message about the file being “changed in memory and on disk”.

    Is there a way around this? I don’t want to turn off the auto-save feature as it’s very useful but I still want to have my File Watcher to run goimports.

    • Alexander Zolotov says:

      Hi Bertram,

      > But, as I’m typing, and the auto-save kicks in

      Have you modified automatically created file watchers? Is ‘Immidiate file synchronization’ option enabled? If so, just disable it and it should work fine.

  7. tsingson says:

    The intention action that initializes structs (added earlier) has been updated and now supports arrays

    this feature is great!!

  8. Brice says:

    For those of use using Webstorm + the Go plugin, to develop in Go please provide a crossgrade to Gogland. I just renewed my yearly subscription to Webstorm, it is now lost money just as is lost the discount for being in my second year :(
    Thank you.

  9. Boris says:

    Thanks for great new features, but I just have one question. Since “On Save” is removed, it seems like “File Watchers” don’t work with Scratch files (it doesn’t run automatically created “goimports” file watcher when saving scratch file). To be honest, I’m now not 100% sure it worked with “On Save” feature, but I remember it did.

    • Alexander Zolotov says:

      Hi Boris,

      File Watchers work on files from a configured scope. By default, it’s Project Files scope. You can copy existing goimports watcher and set Scratches and Consoles for it to make it work on scratches.

      • Boris says:

        Hi Alexander,

        thanks for quick reply, but I still can’t get it to work. I did as you said, but it still doesn’t do anything when I press “cmd+s”. Here are the screenshopt of my settings + my simple scratch test, it should remove “import math” line

        watcher settings + scratch file: https://imgur.com/a/JUFDk

        Thanks.

  10. Obi-Wan says:

    I enabled file watching and added go fmt and goimports. When I save sometimes it does not do the imports. Other times, Gogland freaks out for a couple of seconds. I got a video of it:

    https://drive.google.com/file/d/0B50jK8HJPrs3TjJFRHdpZTBCYVk/view?usp=sharing

    • Alexander Zolotov says:

      Hi, have you modified file watchers? Is ‘Immediate syncronize` checkbox enabled there? Also please try to add ‘$FilePah$’ as an output path of file watcher.

  11. Karl says:

    Just wanted to say @Andrey. Cheptsov and @Alexander.Zolotov, Gogland is a *really* nice IDE.

    You should both be very proud!

    Although it may not be my most-used JetBrains product, it is certainly my favourite!

    I look forward to the features introduced in each release, so you have my thanks.

    Also, I used the original Gogland announcement as a personal excuse to learn the language – it was the best decision I’ve made in a couple of years :)

  12. Michael Whatcott says:

    Regardless of the mechanism we use to run goimports or gofmt, I’d really like to be able to “undo” a goimports or gofmt without the need to confirm a reload from disk. Is that on the roadmap?

Leave a Reply

Your email address will not be published. Required fields are marked *