goofimports: Files | Directories

Command goofimports

Command goimports updates your Go import lines, adding missing ones and removing unreferenced ones.

$ go get

It's a drop-in replacement for your editor's gofmt-on-save hook. It has the same command-line interface as gofmt and formats your code in the same way.

For emacs, make sure you have the latest go-mode.el:

Then in your .emacs file:

(setq gofmt-command "goimports")
(add-to-list 'load-path "/home/you/somewhere/emacs/")
(require 'go-mode-load)
(add-hook 'before-save-hook 'gofmt-before-save)

For vim, set "gofmt_command" to "goimports":

For GoSublime, follow the steps described here:

For other editors, you probably know what to do.

Happy hacking!

Package Files

doc.go goimports.go


importsPackage imports implements a Go pretty-printer (like package "go/format") that also adds or removes import statements as necessary.

Package main imports 12 packages (graph). Updated 2016-07-30. Refresh now. Tools for package owners. This is an inactive package (no imports and no commits in at least two years).