2.0.0-beta-4
Pre-release
Pre-release
- BREAKING CHANGE: Removed experimental
deserializerinterface and
supporting code. Applications using this interface should migrate to the
Unmarshalerinterface by implementingUnmarshalMaxMindDB(d *Decoder) error
instead. OpenandFromBytesnow accept options.- BREAKING CHANGE:
IncludeNetworksWithoutDataandIncludeAliasedNetworks
now return aNetworksOptionrather than being one themselves. These must now
be called as functions:Networks(IncludeAliasedNetworks())instead of
Networks(IncludeAliasedNetworks). This was done to improve the documentation
organization. - Added
Unmarshalerinterface to allow custom decoding implementations for
performance-critical applications. Types implementing
UnmarshalMaxMindDB(d *Decoder) errorwill automatically use custom decoding
logic instead of reflection, following the same pattern as
json.Unmarshaler. - Added public
Decodertype andKindconstants inmmdbdatapackage for
manual decoding.Decoderprovides methods likeReadMap(),ReadSlice(),
ReadString(),ReadUInt32(),PeekKind(), etc.Kindtype includes
helper methodsString(),IsContainer(), andIsScalar()for type
introspection. The mainmaxminddbpackage re-exports these types for
backward compatibility.NewDecoder()supports an options pattern for
future extensibility. - Enhanced
UnmarshalMaxMindDBto work with nested struct fields, slice
elements, and map values. The custom unmarshaler is now called recursively
for any type that implements theUnmarshalerinterface, similar to
encoding/json. - Improved error messages to include byte offset information and, for the
reflection-based API, path information for nested structures using JSON
Pointer format. For example, errors may now show "at offset 1234, path
/city/names/en" or "at offset 1234, path /list/0/name" instead of just the
underlying error message. - PERFORMANCE: Added string interning optimization that reduces allocations
while maintaining thread safety. Reduces allocation count from 33 to 10 per
operation in downstream libraries. Uses a fixed 512-entry cache with per-entry
mutexes for bounded memory usage (~8KB) while minimizing lock contention.