2013-12-19 15:26:26 -07:00
|
|
|
/*
|
|
|
|
|
|
|
|
Command goimports updates your Go import lines,
|
|
|
|
adding missing ones and removing unreferenced ones.
|
2013-12-17 19:21:03 -07:00
|
|
|
|
|
|
|
$ go get code.google.com/p/go.tools/cmd/goimports
|
|
|
|
|
2014-02-12 09:35:02 -07:00
|
|
|
It's a drop-in replacement for your editor's gofmt-on-save hook.
|
|
|
|
It has the the same command-line interface as gofmt and formats
|
|
|
|
your code in the same way.
|
2013-12-17 19:21:03 -07:00
|
|
|
|
2014-02-12 09:35:02 -07:00
|
|
|
For emacs, make sure you have the latest (Go 1.2+) go-mode.el:
|
2013-12-17 19:21:03 -07:00
|
|
|
https://go.googlecode.com/hg/misc/emacs/go-mode.el
|
|
|
|
Then in your .emacs file:
|
|
|
|
(setq gofmt-command "goimports")
|
|
|
|
(add-to-list 'load-path "/home/you/goroot/misc/emacs/")
|
|
|
|
(require 'go-mode-load)
|
|
|
|
(add-hook 'before-save-hook 'gofmt-before-save)
|
|
|
|
|
|
|
|
For vim, set "gofmt_command" to "goimports":
|
|
|
|
https://code.google.com/p/go/source/detail?r=39c724dd7f252
|
|
|
|
https://code.google.com/p/go/source/browse#hg%2Fmisc%2Fvim
|
|
|
|
etc
|
|
|
|
|
|
|
|
For GoSublime, follow the steps described here:
|
2014-01-02 12:02:13 -07:00
|
|
|
http://michaelwhatcott.com/gosublime-goimports/
|
2013-12-17 19:21:03 -07:00
|
|
|
|
|
|
|
For other editors, you probably know what to do.
|
|
|
|
|
|
|
|
Happy hacking!
|
2013-12-19 15:26:26 -07:00
|
|
|
|
|
|
|
*/
|
|
|
|
package main
|