Add v1-preserving format tags to time.Duration and [N]byte fields
org.openrewrite.golang.migration.AddV1FormatTagsArtifactgithub.com/moderneinc/recipes-goAdd json:",format:nano" to time.Duration struct fields and json:",format:array" to fixed [N]byte array struct fields, whose default encoding/json/v2 encoding otherwise diverges from v1 (a duration string rather than a nanosecond number, and a base64 string rather than a number array). With the tag the field encodes identically under encoding/json and encoding/json/v2, so MigrateToJSONV2 migrates the file on its default path rather than leaving it for review. An existing json tag gains the option while its name and other options are kept, and a field that already pins a format is left unchanged.
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.AddV1FormatTagsIf the recipe isn’t available locally, install it with:
mod config recipes go install github.com/moderneinc/recipes-go