Execute gofmt on file save in IntelliJ

I use IntelliJ with the Golang plugin. Is it possible to configure the IDE to execute gofmt on file save?

1 Like

Of course you can.

  1. install File Watchers plugin
  2. open “Preferences->Tools->File Watchers” & Add a new watcher
  3. set File Type : Go , Program : the abosolute path of gofmt , Arguments : -w $FilePath$
  4. click OK

enter image description here

Refer: stackoverflow.com