One thing I miss when switching from VS Code to GoLand is the ability to auto-format the code with go fmt when saving the files.

You need to navigate to Tools > Go Tools > Go Fmt Project to run it, or use the keyboard shortcut which is ⌥⇧⌘P. Still, this is something that you can easily forget to run every single time.

Luckily, GoLand have built in file watchers that you can use to run go fmt every time there’s a file changes.

Here’s how;

  1. Go to Preferences > Tools > File Watchers
  2. Click on the Add button and choose go fmt
  3. Click on the OK button to enable it

How to set Goland File Watchers to run go fmt

That’s it. Now when you saved your code, the file watchers will detect this changes and run go fmt. You can even use file watchers to run other go tools like goimports, go vet or anything else that you think is helpful to you.

  1. GoLand integrations with go tools
  2. Goland file watchers