github.com/april1989/origin-go-tools@v0.0.32/cmd/goimports/doc.go (about) 1 /* 2 3 Command goimports updates your Go import lines, 4 adding missing ones and removing unreferenced ones. 5 6 $ go get github.com/april1989/origin-go-tools/cmd/goimports 7 8 In addition to fixing imports, goimports also formats 9 your code in the same style as gofmt so it can be used 10 as a replacement for your editor's gofmt-on-save hook. 11 12 For emacs, make sure you have the latest go-mode.el: 13 https://github.com/dominikh/go-mode.el 14 Then in your .emacs file: 15 (setq gofmt-command "goimports") 16 (add-hook 'before-save-hook 'gofmt-before-save) 17 18 For vim, set "gofmt_command" to "goimports": 19 https://golang.org/change/39c724dd7f252 20 https://golang.org/wiki/IDEsAndTextEditorPlugins 21 etc 22 23 For GoSublime, follow the steps described here: 24 http://michaelwhatcott.com/gosublime-goimports/ 25 26 For other editors, you probably know what to do. 27 28 To exclude directories in your $GOPATH from being scanned for Go 29 files, goimports respects a configuration file at 30 $GOPATH/src/.goimportsignore which may contain blank lines, comment 31 lines (beginning with '#'), or lines naming a directory relative to 32 the configuration file to ignore when scanning. No globbing or regex 33 patterns are allowed. Use the "-v" verbose flag to verify it's 34 working and see what goimports is doing. 35 36 File bugs or feature requests at: 37 38 https://golang.org/issues/new?title=x/tools/cmd/goimports:+ 39 40 Happy hacking! 41 42 */ 43 package main // import "github.com/april1989/origin-go-tools/cmd/goimports"