← All recipes
Moderne licensed

Remove unused go.mod requirements

Recipe IDorg.openrewrite.golang.migration.RemoveUnusedGoModRequiresArtifactgithub.com/moderneinc/recipes-go

Remove require directives whose module provides no imported package and is unreachable through the module graph from any module that does. Uses the package→module map and module graph resolved at parse time; a no-op when that resolution did not run. Modules that pin a transitive version are kept, so the removal is build-safe.

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.migration.RemoveUnusedGoModRequires

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

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