EVERYTHING XIAOMI
Get listed

gofmt

gofmt is the Go source formatter included with Go installations, available on Linux, macOS, and Windows.

Place
#22 of 34
Score
6.0
gofmt's website

What gofmt is

gofmt is the Go source formatter included with Go installations, available on Linux, macOS, and Windows. It formats Go programs with tabs for indentation and spaces for alignment. Run without a path, it reads standard input; given a directory, it processes .go files recursively and skips files whose names begin with a period. Its default output is reformatted source on standard output. Flags can show differences, identify files that need formatting, apply rewrite rules, simplify code, or report all errors. The rewrite option uses patterns and replacements written as valid Go expressions. gofmt also reshapes Go documentation comments into standard paragraphs, lists, headings, links, and code blocks. Editor integrations are documented for Vim, Emacs, Eclipse, and Sublime Text, as well as Git pre-commit hooks and Mercurial. Since Go 1.18, it reads and formats files concurrently, with memory use limited in proportion to GOMAXPROCS. The executable is equivalent to `go fmt`. It is free and distributed as part of the open-source Go project under a BSD-style license.

Good

  • Included in Go installations at no extra cost.
  • Processes directories recursively for .go files.
  • Can show diffs or list files needing formatting.
  • Formats documentation comments into structured forms.
  • Editor integrations include Vim and Sublime Text.

Watch out

  • Supports Go source only.
  • Skips files beginning with a period during directory processing.
  • No changed-lines-only formatting is listed.

Who it suits

gofmt suits Go developers who want consistent formatting from the command line or an editor integration. It can also fit workflows that use Git pre-commit hooks or Mercurial.

Verdict

gofmt is a focused formatter for Go source, with command-line options and documented editor and version-control integrations. Its directory processing skips hidden-name files, so account for that when formatting a tree.

Plans and prices

From gofmt's own pricing page, checked 1 Oct 2026.

All about pricing
PlanPriceWhat it gives you
gofmtFreeincluded executable in Go installation · command-line use

The facts

Each one read from gofmt's own pages, with the date it was checked.

What it does

Comment formatting
Gofmt reformats Go documentation comments into canonical paragraphs, lists, headings, links, and code blocks.checked 1 Oct 2026
Distribution
The Go installation process installs an executable called gofmt, equivalent to go fmt.checked 1 Oct 2026
Editor integrations
The Go project documents gofmt integrations for Vim, Emacs, Eclipse, Sublime Text, Git pre-commit hooks, and Mercurial.checked 1 Oct 2026
Formatting options
Its flags include displaying diffs, listing files with formatting differences, applying rewrite rules, simplifying code, and reporting all errors.checked 1 Oct 2026
Input handling
Without an explicit path, gofmt processes standard input; with a directory, it recursively processes .go files while ignoring files beginning with a period.checked 1 Oct 2026
License
Go is an open source project distributed under a BSD-style license.checked 1 Oct 2026
Output
By default, gofmt prints reformatted sources to standard output.checked 1 Oct 2026
Performance
Since Go 1.18, gofmt reads and formats input files concurrently with memory limited proportionally to GOMAXPROCS.checked 1 Oct 2026
Purpose
Gofmt automatically formats Go programs using tabs for indentation and blanks for alignment.checked 1 Oct 2026
Security
The Go project issues security fixes to the two most recent major Go releases and provides a security policy for reporting vulnerabilities.checked 1 Oct 2026
Source transformation
The -r flag applies rewrite rules whose patterns and replacements are valid Go expressions.checked 1 Oct 2026
Support
Questions about using Go or announcements relevant to Go users should be sent to the golang-nuts mailing list.checked 1 Oct 2026

Where it runs

Platforms
The Go compiler toolchain can target AIX, Android, DragonFly BSD, FreeBSD, Illumos, Linux, macOS/iOS, NetBSD, OpenBSD, Plan 9, Solaris, and Windows.checked 1 Oct 2026

Alternatives to gofmt

All alternatives
  1. 1Prettier logo

    Prettier

    Free planOpen sourceWebAPIExtensionLinux
    7.5Free plan
  2. 2

    Avidemux

    Free planOpen sourceWebLinuxmacOSWindows
    7.3Free plan
  3. 3

    Fourmolu

    Free planWebLinuxWindows
    6.7Free plan
  4. 4

    rustfmt

    Free planLinuxmacOSWindows
    6.6Free plan
  5. 5

    Black

    Free planLinuxmacOSSelf-hostedWindows
    6.5Free plan
  6. 6Ruff logo

    Ruff

    Free planWebLinuxmacOSSelf-hosted
    6.5Free plan