Releases: oschwald/maxminddb-golang
Releases · oschwald/maxminddb-golang
v2.0.0-beta.7
2.0.0-beta.7
- Update capitalization of "uint" in
ReadUInt*
to matchKindUint*
as well
as the Go standard library.
2.0.0-beta.6
2.0.0-beta.6
- Update capitalization of "uint" in
ReadUInt*
to matchKindUint*
as well
as the Go standard library.
2.0.0-beta.5
2.0.0-beta.5
- Added
Offset()
method toDecoder
to get the current database offset. This
enables custom unmarshalers to implement caching for improved performance when
loading databases with duplicate data structures. - Fixed infinite recursion in pointer-to-pointer data structures, which are
invalid per the MaxMind DB specification.
2.0.0-beta-4
- BREAKING CHANGE: Removed experimental
deserializer
interface and
supporting code. Applications using this interface should migrate to the
Unmarshaler
interface by implementingUnmarshalMaxMindDB(d *Decoder) error
instead. Open
andFromBytes
now accept options.- BREAKING CHANGE:
IncludeNetworksWithoutData
andIncludeAliasedNetworks
now return aNetworksOption
rather 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
Unmarshaler
interface to allow custom decoding implementations for
performance-critical applications. Types implementing
UnmarshalMaxMindDB(d *Decoder) error
will automatically use custom decoding
logic instead of reflection, following the same pattern as
json.Unmarshaler
. - Added public
Decoder
type andKind
constants inmmdbdata
package for
manual decoding.Decoder
provides methods likeReadMap()
,ReadSlice()
,
ReadString()
,ReadUInt32()
,PeekKind()
, etc.Kind
type includes
helper methodsString()
,IsContainer()
, andIsScalar()
for type
introspection. The mainmaxminddb
package re-exports these types for
backward compatibility.NewDecoder()
supports an options pattern for
future extensibility. - Enhanced
UnmarshalMaxMindDB
to work with nested struct fields, slice
elements, and map values. The custom unmarshaler is now called recursively
for any type that implements theUnmarshaler
interface, 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.
2.0.0-beta.3
Open
will now fall back to loading the database in memory if the file-system does not supportmmap
. Pull request by database64128. GitHub #163.- Made significant improvements to the Windows memory-map handling. . GitHub #162.
- Fix an integer overflow on large databases when using a 32-bit architecture. See ipinfo/mmdbctl#33.
2.0.0-beta.2
2.0.0-beta.1
This is the first beta of the v2 releases. Go 1.23 is required. I don't expect to do a final release until Go 1.24 is available. See #141 for the v2 roadmap.
Notable changes:
(*Reader).Lookup
now takes only the IP address and returns aResult
.Lookup(ip, &rec)
would now becomeLookup(ip).Decode(&rec)
.(*Reader).LookupNetwork
has been removed. To get the network for a result, use(Result).Prefix()
.(*Reader).LookupOffset
now takes an offset and returns aResult
.Result
has anOffset()
method that returns the offset value.(*Reader).Decode
has been removed.- Use of
net.IP
and*net.IPNet
have been replaced withnetip.Addr
andnetip.Prefix
. - You may now decode a particular path within a database record using
(Result).DecodePath
. For instance, to decode just the country code in GeoLite2 Country to a string calledcode
, you might do something likeLookup(ip).DecodePath(&code, "country", "iso_code")
. Strings should be used for map keys and ints for array indexes. (*Reader).Networks
and(*Reader).NetworksWithin
now return a Go 1.23 iterator ofResult
values. Aliased networks are now skipped by default. If you wish to include them, use theIncludeAliasedNetworks
option.
1.13.1
- Return the
*net.IPNet
in canonical form when usingNetworksWithin
to look up a network more specific than the one in the database. Previously, theIP
field on the*net.IPNet
would be set to the IP from the lookup network rather than the first IP of the network. NetworksWithin
will now correctly handle an*net.IPNet
parameter that is not in canonical form. This issue would only occur if the*net.IPNet
was manually constructed, asnet.ParseCIDR
returns the value in canonical form even if the input string is not.
1.13.0
1.12.0
- The
wasi
target is now built without memory-mapping support. Pull request
by Alex Kashintsev. GitHub #114. - When decoding to a map of non-scalar, non-interface types such as a
map[string]map[string]any
, the decoder failed to zero out the value for
the map elements, which could result in incorrect decoding. Reported by
JT Olio. GitHub #115.