← All recipes
Moderne licensed

Avoid lock in loop

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

Find Lock() or RLock() calls inside for/range loops. Acquiring locks in tight loops can cause contention; consider locking once 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.AvoidLockInLoop

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

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