Skip to content
Latchkey

gofumpt -l / -d reports unformatted files in CI

gofumpt is a stricter superset of gofmt. gofumpt -l lists files that do not match its stricter rules, and a CI gate fails when that list is non-empty, even for code that gofmt accepts.

What this error means

A gofumpt step lists files and exits non-zero, sometimes flagging code that already passed gofmt (extra blank-line, grouping, and statement rules).

gofumpt
$ test -z "$(gofumpt -l .)"
cmd/app/main.go
Error: Process completed with exit code 1.

Common causes

gofumpt enforces rules gofmt does not

gofumpt adds formatting rules on top of gofmt, so passing gofmt is not enough to pass gofumpt.

Files were formatted with gofmt only

Code run through gofmt (but not gofumpt) still differs from gofumpt's stricter output.

How to fix it

Run gofumpt -w and commit

  1. Install gofumpt and run gofumpt -w ..
  2. Commit the changes.
  3. Re-run gofumpt -l . and confirm it is empty.
Terminal
go install mvdan.cc/gofumpt@latest
gofumpt -w .
gofumpt -l .   # expect empty

Use gofumpt consistently or enable it in golangci-lint

Pick gofumpt everywhere (editor + CI) or enable the gofumpt linter in golangci-lint so local and CI agree.

How to prevent it

  • Use gofumpt for format-on-save if CI uses gofumpt.
  • Pin the gofumpt version to avoid rule drift.
  • Enable the gofumpt formatter in golangci-lint for one source of truth.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →