Freedom251 › Code Formatting Tools
goimports

What goimports is
goimports is a free, open-source command-line tool for Go developers. It updates import lines by adding imports required by the code and removing those that are unused, then formats code in the same style as gofmt. It can replace an editor’s gofmt-on-save hook. The package page gives `go install golang.org/x/tools/cmd/goimports@latest` as the installation command.
Documentation describes use with Emacs, Vim, and GoSublime, and says it can be configured for other editors. For controlling directory scans, goimports reads `$GOPATH/src/.goimportsignore`; the file accepts blank lines, comments, and directory names, but not globbing or regular-expression patterns. Its `-v` flag provides verbose output to help inspect activity and check exclusions. 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. Bug reports and feature requests are directed to the Go issue tracker.
Who it suits
goimports suits Go developers who want imports corrected and code formatted in an editor workflow. It is also relevant to users who need to exclude directories from import scanning.
What it does well
- Adds missing imports and removes unreferenced ones.
- Formats code in the gofmt style.
- Documented integrations include Emacs, Vim, and GoSublime.
- Free, redistributable, and licensed under BSD-3-Clause.
What to know first
- Ignore files do not support globbing or regular expressions.
- The listed package version is not the latest in its module.
Limits
Directory exclusions accept directory names, comments, and blank lines, but not globbing or regular-expression patterns.
Plans
| Plan | Billed and limits | Price |
|---|---|---|
| Free | Open source command-line tool · BSD-3-Clause license | Free |
As pkg.go.dev lists them, read 8 Oct 2026. The maker's own page has the final word.
Getting started
- Install it with `go install golang.org/x/tools/cmd/goimports@latest`.
- Configure an editor integration; documentation describes Emacs, Vim, and GoSublime, and allows configuration for other editors.
- Add directory exclusions to `$GOPATH/src/.goimportsignore` using directory names, comments, or blank lines.
- Use the `-v` flag to inspect activity and check directory exclusions.
Overview
goimports is a Go command-line tool that adds missing imports, removes unused ones and formats code in gofmt’s style. It suits Go developers who want import cleanup built into an editor workflow. Its free, open-source offering is focused and practical, though directory exclusions accept only a simple list of names.
Key features
Import management and formatting come together: goimports updates import lines and formats code in the same style as gofmt. That makes it a natural option for developers who want one editor save hook to handle both jobs; it can replace a gofmt-on-save hook.
Documentation covers integration with Emacs, Vim and GoSublime, and says other editors can be configured. The package page gives go install golang.org/x/tools/cmd/goimports@latest as the installation command.
To keep directories out of its scan, goimports reads $GOPATH/src/.goimportsignore. The file supports blank lines, comments and directory names, but not globbing or regular-expression patterns. That is adequate for straightforward exclusions, but limiting when teams need pattern-based rules. The -v flag provides verbose output to help check exclusions and see what the tool is doing.
Pricing
goimports is free: its plan costs free and provides an open-source command-line tool under the BSD-3-Clause license. There is no free trial because no paid plan is needed to use it. The license is marked redistributable. This is a direct fit for Go developers seeking a no-cost formatter and import manager, without a paid tier to weigh against the free version.
Platforms
The package supports Linux, macOS, Windows and web. It is a command-line tool with editor integration; the documentation describes workflows for Emacs, Vim and GoSublime and allows configuration for other editors. Go is its supported language. The package page identifies version v0.51.0 and says it is not the latest version of its module, a consideration for users who prioritize the newest module release.
Who it's for
Choose goimports if you write Go and want import cleanup and gofmt-style formatting in an editor workflow, especially if simple directory exclusions are enough. Look elsewhere if you need glob or regex exclusions, or if your code-formatting needs center on another language.
Pros and cons
- Pros: Combines missing- and unused-import cleanup with gofmt-style formatting, so one tool can handle both in an editor save workflow.
- Pros: Free and redistributable under BSD-3-Clause, with integrations documented for several editors and configuration possible for others.
- Cons: Exclusions support directory names, comments and blank lines, but not globbing or regular expressions.
- Cons: The package page identifies v0.51.0 as not the latest version of its module, which may matter to users seeking the newest release.
Alternatives
For a broader comparison, browse Code Formatting Tools. Pick another formatter when its language or stated role better matches your work:
- Black is a free, MIT-licensed Python code formatter, so it is the more relevant choice for Python rather than Go.
- Fantomas is a free F# source formatter delivered as a .NET tool, making it a better match for F# projects.
- Fourmolu and Ormolu are free open-source Haskell formatters; choose one when formatting Haskell is the priority.
- Prettier is a free open-source code formatter with support across API, extension and common desktop and web platforms; it fits readers seeking a formatter beyond Go.
- Ruff targets the Python ecosystem, so it is the alternative to consider for Python development.
- rustfmt is free and has no paid plans stated; choose it when Rust is your language.
- Accessibility Test Framework for Android is a free Android-focused alternative.
Verdict
Go developers who want import correction and gofmt-style formatting in an editor should choose goimports: it combines those jobs at no cost and supports documented workflows in several editors. Choose a different tool for another programming language, or when directory exclusions need glob or regex patterns.
Verdict
goimports combines import cleanup with gofmt-style formatting and can fit into several documented editor workflows. Its directory exclusions use a deliberately limited file format, and the package page notes that its listed version is not the latest in its module.
Questions
How much does goimports cost?
The listed Free plan costs nothing.
Which platforms does it support?
Listed platforms are Linux, macOS, Windows, and web.
What does goimports do?
It adds missing Go imports, removes unreferenced imports, and formats code in the same style as gofmt.
Which license does it use?
The package page identifies the BSD-3-Clause license and marks it redistributable.
How can I install it?
The package page gives `go install golang.org/x/tools/cmd/goimports@latest` as the installation command.
Which editors are documented?
The documentation describes using goimports with Emacs, Vim, and GoSublime, and says it can be configured for other editors.
Facts from goimports's own pages
- 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. · pkg.go.dev, 8 Oct 2026
- Editor integrations
- The documentation describes using goimports with Emacs, Vim, and GoSublime, and says it can be configured for other editors. · pkg.go.dev, 8 Oct 2026
- Formatting
- It formats code in the same style as gofmt and can replace an editor’s gofmt-on-save hook. · pkg.go.dev, 8 Oct 2026
- Installation
- The package page gives `go install golang.org/x/tools/cmd/goimports@latest` as the installation command. · pkg.go.dev, 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. · pkg.go.dev, 8 Oct 2026
- License
- The package page identifies its license as BSD-3-Clause and marks it redistributable. · pkg.go.dev, 8 Oct 2026
- Purpose
- goimports updates Go import lines by adding missing imports and removing unreferenced imports. · pkg.go.dev, 8 Oct 2026
- Support
- The package documentation directs users to the Go issue tracker for bugs and feature requests. · pkg.go.dev, 8 Oct 2026
- Verbose mode
- The `-v` flag provides verbose output to help verify directory exclusions and see what goimports is doing. · pkg.go.dev, 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. · pkg.go.dev, 8 Oct 2026
Where goimports stands on Freedom251
- Code Formatting Tools#10 of 34