← All recipes
Moderne licensed

Adopt testify assert.Nil

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

Replace if x != nil { t.Error(...) } with assert.Nil(t, x) and if x == nil { t.Error(...) } with assert.NotNil(t, x) from github.com/stretchr/testify/assert, 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.AdoptTestifyAssertNil

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

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