Migrate encoding/json to encoding/json/v2 (all mechanical rewrites)
Recipe ID
org.openrewrite.golang.migration.MigrateToJSONV2Artifactgithub.com/moderneinc/recipes-goMigrate the mechanical encoding/json idioms to encoding/json/v2 by composing the streaming, MarshalIndent, function-local Encoder/Decoder, and RawMessage rewrites plus an import-only swap for files whose usage already exists in v2, adopting v2 semantics. To keep v1 output byte-identical instead, run the opt-in PreserveV1Semantics recipe afterwards.
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.MigrateToJSONV2If the recipe isn’t available locally, install it with:
mod config recipes go install github.com/moderneinc/recipes-go