Stupid Emacs trick for writing Go code
Lately, I have been writing more code outside of full-fleged IDEs and found myself
tweaking Emacs into a lightweight IDE for Go. Having gofmt
automagically formatting the
code and refreshing it in the buffer is simply lovely. My current go-mode
cusomization
looks like this:
First, get the excellent go-playground
package.
(package-install 'go-playround)
Then, configure Emacs
;; Automatically format your code on save
(add-hook 'before-save-hook 'gofmt-before-save)
;; Automatically display gofmt processed code in buffers
(custom-set-variables
'(global-auto-revert-mode t)
'(auto-revert-interval 1))
;; Verbose output when running tests via go-test-current-*
(setq go-test-args "-v")