github.com/graybobo/golang.org-package-offline-cache@v0.0.0-20200626051047-6608995c132f/x/tools/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 golang.org/x/tools/cmd/goimports 7 8 It's a drop-in replacement for your editor's gofmt-on-save hook. 9 It has the same command-line interface as gofmt and formats 10 your code in the same way. 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-to-list 'load-path "/home/you/somewhere/emacs/") 17 (require 'go-mode-load) 18 (add-hook 'before-save-hook 'gofmt-before-save) 19 20 For vim, set "gofmt_command" to "goimports": 21 https://golang.org/change/39c724dd7f252 22 https://golang.org/wiki/IDEsAndTextEditorPlugins 23 etc 24 25 For GoSublime, follow the steps described here: 26 http://michaelwhatcott.com/gosublime-goimports/ 27 28 For other editors, you probably know what to do. 29 30 Happy hacking! 31 32 */ 33 package main // import "golang.org/x/tools/cmd/goimports"