← All recipes
Moderne licensed

Prefer %w over %s in fmt.Errorf for error wrapping

Recipe IDorg.openrewrite.golang.codequality.PreferErrorfWrapVerbArtifactgithub.com/moderneinc/recipes-go

Replace %s with %w in fmt.Errorf format strings when the corresponding argument is an error, to preserve the error chain.

Single recipeProprietary

Usage

This recipe has no required configuration options. You’ll need the Moderne CLI configured before running the command below.

mod run . --recipe org.openrewrite.golang.codequality.PreferErrorfWrapVerb

If the recipe isn’t available locally, install it with:

mod config recipes go install github.com/moderneinc/recipes-go