← All recipes
Moderne licensed

Avoid fmt in loop

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

Find fmt.Sprintf, fmt.Sprint, or fmt.Fprintf calls inside for/range loops. These allocate on every call; prefer direct string operations or strconv.

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

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

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