← All recipes
Moderne licensed

Adopt testify require.Nil

Recipe IDorg.openrewrite.golang.testify.AdoptTestifyRequireNilArtifactgithub.com/moderneinc/recipes-go

Replace if x != nil { t.Fatal(...) } with require.Nil(t, x) and if x == nil { t.Fatal(...) } with require.NotNil(t, x) from github.com/stretchr/testify/require, for non-error operands. Error operands are handled by the NoError / Error recipes.

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.testify.AdoptTestifyRequireNil

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

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