Run goimports on file save in emacs
This post documents how to run goimports with every file save in Emacs
Get goimports
goimports is a drop-in replacement for gofmt
$ go get golang.org/x/tools/cmd/goimports
Change init.el
Change the emacs init file
(setq gofmt-command "goimports")
(add-hook 'before-save-hook 'gofmt-before-save)
M-x eval-buffer