Add import
Recipe ID
org.openrewrite.golang.AddImportArtifactgithub.com/moderneinc/recipes-goAdd an import statement to a Go compilation unit. No-op if the import is already present in a compatible form.
Single recipeProprietary
Usage
You’ll need the Moderne CLI configured before running the command below.
mod run . --recipe org.openrewrite.golang.AddImport --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 add. e.g. fmt |
onlyIfReferenced | Boolean | When true, add the import only if some identifier in the file already references the package via type attribution. |