goimports
goimports is a free, open-source command-line tool for Go developers.
What goimports is
goimports is a free, open-source command-line tool for Go developers. It updates Go import lines by adding missing imports and removing those that are not referenced. It also formats code in the same style as gofmt, and can replace an editor’s gofmt-on-save hook. The documented installation command is `go install golang.org/x/tools/cmd/goimports@latest`. Documentation describes integrations with Emacs, Vim, and GoSublime, and says the tool can be configured for other editors. For directory scanning, goimports reads `$GOPATH/src/.goimportsignore`. That file accepts blank lines, comments, or directory names, but does not support globbing or regular-expression patterns. The `-v` flag provides verbose output to help check exclusions and see what the tool is doing. The package page lists version v0.51.0 and notes that it is not in the latest version of its module. It identifies the BSD-3-Clause license and marks the package redistributable. The documentation directs bug reports and feature requests to the Go issue tracker.
Good
- Adds missing and removes unused Go imports.
- Formats code in the style of gofmt.
- Documents integrations with Emacs, Vim, and GoSublime.
- Supports directory exclusions through .goimportsignore.
Watch out
- The ignore file does not support globbing or regex patterns.
- The package page says it is not in the latest module version.
Who it suits
goimports suits Go developers who want imports corrected and code formatted as part of an editor workflow. It may also help those who need to exclude directories from scanning.
Verdict
goimports handles import cleanup and gofmt-style formatting in one command-line tool. Its editor integrations and directory exclusions make it adaptable, though its ignore-file syntax is limited.
Plans and prices
From goimports's own pricing page, checked 8 Oct 2026.
| Plan | Price | What it gives you |
|---|---|---|
| Free | Free | Open source command-line tool · BSD-3-Clause license |
The facts
Each one read from goimports's own pages, with the date it was checked.
What it does
- Directory exclusions
- It reads `$GOPATH/src/.goimportsignore` to exclude directories from scanning, with blank lines, comments, or directory names and no globbing or regex patterns.checked 8 Oct 2026
- Editor integrations
- The documentation describes using goimports with Emacs, Vim, and GoSublime, and says it can be configured for other editors.checked 8 Oct 2026
- Formatting
- It formats code in the same style as gofmt and can replace an editor’s gofmt-on-save hook.checked 8 Oct 2026
- Installation
- The package page gives `go install golang.org/x/tools/cmd/goimports@latest` as the installation command.checked 8 Oct 2026
- Intended users
- The documentation presents goimports as a tool for Go developers who want imports corrected and code formatted in their editor workflow.checked 8 Oct 2026
- License
- The package page identifies its license as BSD-3-Clause and marks it redistributable.checked 8 Oct 2026
- Purpose
- goimports updates Go import lines by adding missing imports and removing unreferenced imports.checked 8 Oct 2026
- Support
- The package documentation directs users to the Go issue tracker for bugs and feature requests.checked 8 Oct 2026
- Verbose mode
- The `-v` flag provides verbose output to help verify directory exclusions and see what goimports is doing.checked 8 Oct 2026
- Version status
- The package page identifies version v0.51.0 and notes that the package is not in the latest version of its module.checked 8 Oct 2026
Alternatives to goimports
- 1

Prettier
Free planOpen sourceWebAPIExtensionLinux7.5Free plan - 2
Avidemux
Free planOpen sourceWebLinuxmacOSWindows7.3Free plan - 3
Fourmolu
Free planWebLinuxWindows6.7Free plan - 4
rustfmt
Free planLinuxmacOSWindows6.6Free plan - 5
Black
Free planLinuxmacOSSelf-hostedWindows6.5Free plan - 6

Ruff
Free planWebLinuxmacOSSelf-hosted6.5Free plan
