I use IntelliJ with the Golang plugin. Is it possible to configure the IDE to execute gofmt on file save?
Of course you can.
File Type
: Go
, Program
: the abosolute path of gofmt
, Arguments
: -w $FilePath$
OK
Gogland EAP 16 deprecated the On Save actions and replaced them with the File Watchers plugin.
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, check if you have File Watchers plugin and if not install it.
Enable gofmt:
Settings | Tools | File Watchers
.+
button and select go fmt
.You can do the same for goimports
and gometalinter
.