Open file outside loop
Recipe ID
org.openrewrite.golang.codequality.OpenFileOutsideLoopArtifactgithub.com/moderneinc/recipes-goFind os.Open() or os.Create() calls inside for/range loops. Opening files in tight loops should use a single open outside the loop.
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.OpenFileOutsideLoopIf the recipe isn’t available locally, install it with:
mod config recipes go install github.com/moderneinc/recipes-go