A Go tool that analyzes and fixes fmt.Errorf() calls to use the new %w error-wrapping verb directive.
errwrap is a Go command-line tool that analyzes Go source code to identify fmt.Errorf() calls that should use the %w error-wrapping verb directive introduced in Go 1.13. It helps developers migrate their error handling patterns to support proper error wrapping and inspection, and can automatically fix detected issues.
Go developers maintaining codebases that need to adopt Go 1.13+ error wrapping conventions, particularly those working on larger projects where manual updates would be tedious.
Developers choose errwrap because it automates a tedious but important code migration task, ensures consistent error wrapping patterns across codebases, and integrates seamlessly with existing Go tooling through the go/analysis framework.
Go tool to wrap and fix errors with the new %w verb directive
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Identifies specific fmt.Errorf calls that should use %w, outputting line and column numbers for easy debugging, as shown in the demo output.
With the -fix flag, it rewrites source code in-place to replace error format verbs with %w, saving manual refactoring effort, demonstrated in the diff example.
Built on go/analysis, making it compatible with Go toolchains and editor plugins, ensuring seamless workflow integration.
Accepts files, directories, or package imports for analysis, allowing targeted or broad codebase coverage, as per the usage examples.
Only targets fmt.Errorf calls, missing custom error wrapping methods or other patterns, which limits its utility in diverse codebases.
Automatically fixes calls without considering whether wrapping is appropriate, potentially violating the 'Whether to Wrap' guidelines cautioned in the README.
Requires Go 1.16+ for installation, hindering use in environments with older Go versions or legacy codebases.