Remove import
Recipe ID
org.openrewrite.golang.RemoveImportArtifactgithub.com/moderneinc/recipes-goRemove an import statement from a Go compilation unit. Matches by import path, in any form (regular, aliased, dot, blank). Unless force is set, an import that the file still references is kept, as are blank (_) and dot (.) imports.
Single recipeProprietary
Usage
You’ll need the Moderne CLI configured before running the command below.
mod run . --recipe org.openrewrite.golang.RemoveImport --recipe-option "packagePath=fmt"If the recipe isn’t available locally, install it with:
mod config recipes go install github.com/moderneinc/recipes-goOptions
| Name | Type | Description |
|---|---|---|
packagePathrequired | String | The import path to remove. e.g. fmt |
force | Boolean | When true, remove the import even if the file still references the package, and remove blank (_) and dot (.) imports. |