← All recipes
Moderne licensed

Use package-level error sentinel

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

Move inline errors.New("...") calls to package-level sentinel variables so they can be compared with errors.Is. Each distinct message becomes one sentinel per package, declared in the first file that uses it and referenced from every other.

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.UsePackageLevelErrorSentinel

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

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