Migrate from mitchellh/mapstructure to go-viper/mapstructure/v2
Recipe ID
org.openrewrite.golang.migration.MigrateToGoViperMapstructureArtifactgithub.com/moderneinc/recipes-goMigrate off github.com/mitchellh/mapstructure, unmaintained since 2023, to the community fork github.com/go-viper/mapstructure/v2. v2 keeps every function, hook and DecoderConfig field of v1 and adds more, so this is a path swap. The one exception is the exported Error struct, which v2 replaced with errors.Join; a file naming it is left untouched and reported by FindMapstructureErrorUsage. Run go mod tidy afterwards to sync go.sum.
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.MigrateToGoViperMapstructureIf the recipe isn’t available locally, install it with:
mod config recipes go install github.com/moderneinc/recipes-go