github iskorotkov/avro v2.35.0
v2.35.0 — Go 1.27 support, avrogen field type overrides, and codec cache correctness fixes

2 hours ago

Release notes — v2.35.0

Highlights

  • Go 1.27 support; minimum Go raised to 1.26 — consumers on Go 1.24/1.25 must stay on v2.34.x.
  • Shared Config no longer mixes up same-named types — two schemas defining the same named type differently could share an encoder, silently writing decimals at the wrong scale or swapping enum symbols and record fields.
  • No more stack overflow on recursive schemas — building a skip decoder for a self-referential record crashed at codec construction.
  • avrogen -fieldtype — override the generated Go type of a single field without editing the schema.
  • json-iterator removed — replaced by stdlib encoding/json; the upstream repo was archived in December 2025.

Breaking changes

  • go.mod now requires Go 1.26 (#48). CI covers Go 1.26 and 1.27.

Features

  • feat(avrogen): add field type overrides (#46) — new -fieldtype record.field,goType[,import] flag (repeatable) and gen.WithFieldType / gen.Config.FieldTypes. Union fields get the type exactly as written, so nullable fields need an explicit *. Unused or duplicate overrides are errors (CLI exit code 5; library: Generator.ValidateFieldTypes()). -logicaltype now shares the parser, so commas inside generic type brackets ([...]) are no longer treated as separators.
  • feat: support go 1.27 and raise minimum go version to 1.26 (#48) — adds go fix modernizers and slices/maps rewrites. Each rewrite was benchmark-gated, and one that caused an allocation regression was reverted.

Fixes

  • fix(codec): key codec caches on referenced named type definitions (#54, fixes #52) — CacheFingerprint() now also hashes the definitions of externally referenced named types, and the encoder cache uses it like the decoder caches already did. Fingerprint() is unchanged, so single-object encoding, registries and compatibility checks are not affected. CacheFingerprint() values change for schemas that reference external named types; they are documented as a cache identity only.
  • fix: add cycle detection to skip decoder for recursive schemas (#51, thanks @snakeice) — decoding into a struct that omits a recursive field (e.g. map of the enclosing record) no longer recurses infinitely at codec construction.

Performance

  • perf: prebuild union skip decoders at codec construction (#53) — per-branch skip decoders are built once instead of on every value. Compared with v2.34.0: skipping ["null", Record] goes from 103 to 67 ns with 0 allocs (was 3), and a recursive 10-level union list goes from 416 to 147 ns with 0 allocs (was 30).

Dependencies

  • refactor: replace json-iterator with stdlib encoding/json (#40) — removes json-iterator/go and modern-go/concurrent. Schema output is byte-identical, so canonical forms and fingerprints are unchanged.
  • Dependency upgrades: klauspost/compress v1.19.2, mapstructure v2.5.0, testify v1.12.0, and later Go-1.26-compatible tooling (#39, #48). GitHub Actions bumps (#35, #49).

Don't miss a new avro release

NewReleases is sending notifications on new releases.