← All recipes
Moderne licensed

Rename package

Recipe IDorg.openrewrite.golang.RenamePackageArtifactgithub.com/moderneinc/recipes-go

Rename a Go package across a project — rewrites the package declaration in files that own the package, and rewrites import paths in every file that references it.

Single recipeProprietary

Usage

You’ll need the Moderne CLI configured before running the command below.

mod run . --recipe org.openrewrite.golang.RenamePackage --recipe-option "oldPackagePath=github.com/old/foo" --recipe-option "newPackagePath=github.com/new/foo"

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

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

Options

NameTypeDescription
oldPackagePathrequiredStringThe fully qualified package path to rename.
e.g. github.com/old/foo
newPackagePathrequiredStringThe fully qualified package path to use instead.
e.g. github.com/new/foo