finds.dev← search

// the find

fatih/errwrap

★ 380 · Go · NOASSERTION · updated Apr 2025

Go tool to wrap and fix errors with the new %w verb directive

errwrap is a small go/analysis checker that flags fmt.Errorf calls where an error argument is formatted with %v, %s or another verb instead of %w, and can rewrite those calls with -fix. It is for Go developers who want to adopt error wrapping across an existing codebase without editing each call site by hand.

It is built on go/analysis, so it judges by type rather than text: an argument counts because its type is error, not because the format string happens to contain a verb. The analysistest suite pins both the diagnostics and the rewritten output with golden files (a.go.golden, e.go.golden), so changes to the fix show up as a diff in review. The README is candid that wrapping makes the wrapped error part of your API and that the tool does not pretend otherwise.

The last push was April 2025, about eighteen months before this evaluation, so it is unclear whether it has been exercised against recent Go releases and x/tools. -fix converts every error-typed verb to %w, and the README mentions no way to exclude a call site, so a deliberately opaque error gets wrapped anyway unless you skip that file. golangci-lint's errorlint linter has an errorf check that covers the same ground and also handles errors.Is and errors.As, so if you already run golangci-lint, that is probably the better home for this check.

View on GitHub → Homepage ↗

// want more like this?

We dig through GitHub every week and send a few repos picked for what you actually care about — each with an honest take like this one.

Get finds in your inbox → Search again →