- This module now targets Go 1.25+.
- Updated dependencies to latest version. In particular
github.com/oschwald/maxminddb-golang/v2was updated tov2.3.0, which includes several performance improvements.
- Added support for the GeoIP Anonymous Plus database. This database provides
VPN detection with confidence scoring, provider identification, and temporal
tracking via the new
AnonymousPlus()method. - Deprecated
IsLegitimateProxyonEnterpriseTraits. MaxMind has deprecated this field and it will be removed in the next major release. - Deprecated
StaticIPScoreonEnterpriseTraits. This field was added in error and has never been populated. It will be removed in the next major release.
- Upgraded
github.com/oschwald/geoip2-golang/v2to 2.1.1, which fixes an issue that prevented a unclosed memory-mapped file from being unmapped when the reader was garbage collected.
- BREAKING CHANGE: Lookup methods now require
netip.Addr, return typedNames, and provideHasData()helpers while always populatingNetwork/IPAddressfields so network topology remains accessible. - BREAKING CHANGE: Struct field casing now matches MaxMind responses (for
example
IsoCode→ISOCode), location coordinates use pointers, and JSON tags rely on Go 1.24omitzerosupport—upgrade your toolchain before adopting v2. - Added
MIGRATION.mdwith detailed guidance for upgrading from v1. - Updated dependency on
github.com/oschwald/maxminddb-golang/v2tov2.0.0. - Added configurable
Optionhelpers soOpenandOpenBytescan accept future options without forcing a v3 release. - BREAKING CHANGE: Removed deprecated
FromBytesmethod. UseOpenBytesinstead.
- Updated maxminddb dependency to v2.0.0-beta.9.
- Added
OpenBytesmethod to match the API changes in maxminddb v2.0.0-beta.9. - Deprecated
FromBytesmethod. UseOpenBytesinstead.FromByteswill be removed in a future version.
- Added support for
GeoIP-City-Redacted-USandGeoIP-Enterprise-Redacted-US. Requested by Tom Anderson. GitHub #134. - Upgrade
github.com/oschwald/maxminddb-golang/v2tov2.0.0-beta.7.
- BREAKING CHANGE: Replaced
IsZero()methods withHasData()methods on all result structs (including Names). The new methods provide clearer semantics:HasData()returnstruewhen GeoIP data is found andfalsewhen no data is available. UnlikeIsZero(),HasData()excludes Network and IPAddress fields from validation, allowing users to access network topology information even when no GeoIP data is found. The Network and IPAddress fields are now always populated for all lookups, regardless of whether GeoIP data is available. - BREAKING CHANGE: Replaced all anonymous nested structs with named types
to improve struct initialization ergonomics. All result structs (Enterprise,
City, Country) now use named types like
EnterpriseCityRecord,CityTraits,CountryRecord, etc. This makes it much easier to initialize structs in user code while maintaining the same JSON serialization behavior. - BREAKING CHANGE: Changed
Location.LatitudeandLocation.Longitudefromfloat64to*float64to properly distinguish between missing coordinates and the valid location (0, 0). Missing coordinates are now represented asniland are omitted from JSON output, while valid zero coordinates are preserved. This fixes the ambiguity where (0, 0) was incorrectly treated as "no data". AddedLocation.HasCoordinates()method for safe coordinate access. Reported by Nick Bruun. GitHub #5.
- BREAKING CHANGE: Updated to use
maxminddb-golang/v2which provides significant performance improvements and a more modern API. - BREAKING CHANGE: All lookup methods now accept
netip.Addrinstead ofnet.IP. This provides better performance and aligns with modern Go networking practices. - BREAKING CHANGE: Renamed
IsoCodefields toISOCodein all structs to follow proper capitalization for the ISO acronym. Closes GitHub issue #4. - BREAKING CHANGE: Replaced
map[string]stringNames fields with structuredNamestype for significant performance improvements. This eliminates map allocation overhead, reducing memory usage by 34% and allocations by 56%. - BREAKING CHANGE: Added JSON tags to all struct fields. JSON tags match
the corresponding
maxminddbtags where they exist. Custom fields (IPAddressandNetwork) use snake_case (ip_addressandnetwork). - BREAKING CHANGE: Removed
IsAnonymousProxyandIsSatelliteProviderfields from all Traits structs. These fields have been removed from MaxMind databases. Use the dedicated Anonymous IP database for anonymity detection instead. - BREAKING CHANGE: Go 1.24 or greater is now required. This enables the use
of
omitzeroin JSON tags to match MaxMind database behavior where empty values are not included. - Added
IsZero()method to all result structs (City, Country, Enterprise, ASN, etc.) to easily check whether any data was found for the queried IP address. Requested by Salim Alami. GitHub #32. - Added
NetworkandIPAddressfields to all result structs. TheNetworkfield exposes the network prefix from the MaxMind database lookup, and theIPAddressfield contains the IP address used during the lookup. These fields are only populated when data is found for the IP address. For flat record types (ASN, ConnectionType, Domain, ISP, AnonymousIP), the fields are namedNetworkandIPAddress. For complex types (City, Country, Enterprise), the fields are located at.Traits.Networkand.Traits.IPAddress. Requested by Aaron Bishop. GitHub #128. - Updated module path to
github.com/oschwald/geoip2-golang/v2to follow Go's semantic versioning guidelines for breaking changes. - Updated examples and documentation to demonstrate proper error handling with
netip.ParseAddr(). - Updated linting rules to support both v1 and v2 import paths during the transition period.
To migrate from v1 to v2:
-
Update your import path:
// Old import "github.com/oschwald/geoip2-golang" // New import "github.com/oschwald/geoip2-golang/v2"
-
Replace
net.IPwithnetip.Addr:// Old ip := net.ParseIP("81.2.69.142") record, err := db.City(ip) // New ip, err := netip.ParseAddr("81.2.69.142") if err != nil { // handle error } record, err := db.City(ip)
-
Update field names from
IsoCodetoISOCode:// Old countryCode := record.Country.IsoCode subdivisionCode := record.Subdivisions[0].IsoCode // New countryCode := record.Country.ISOCode subdivisionCode := record.Subdivisions[0].ISOCode
-
Replace map-based Names access with struct fields:
// Old cityName := record.City.Names["en"] countryName := record.Country.Names["pt-BR"] continentName := record.Continent.Names["zh-CN"] // New cityName := record.City.Names.English countryName := record.Country.Names.BrazilianPortuguese continentName := record.Continent.Names.SimplifiedChinese
Available Names struct fields:
English(en)German(de)Spanish(es)French(fr)Japanese(ja)BrazilianPortuguese(pt-BR)Russian(ru)SimplifiedChinese(zh-CN)
-
Check if data was found using the new
IsZero()method:record, err := db.City(ip) if err != nil { // handle error } if record.IsZero() { fmt.Println("No data found for this IP") } else { fmt.Printf("City: %s\n", record.City.Names.English) }
- Go 1.21 or greater is now required.
- The new
is_anycastoutput is now supported on the GeoIP2 Country, City, and Enterprise databases. #119.
Note: 1.10.0 was accidentally skipped.
- Rearrange fields in structs to reduce memory usage. Although this does reduce readability, these structs are often created at very rates, making the trade-off worth it.
- Set Go version to 1.18 in go.mod.
- Set the minimum Go version in the go.mod file to 1.17.
- Updated dependencies.
- This is a re-release with the changes that were supposed to be in 1.6.0.
- Add support for new
mobile_country_codeandmobile_network_codeoutputs on GeoIP2 ISP and GeoIP2 Enterprise.
- Add
StaticIPScorefield to Enterprise. Pull request by Pierre Bonzel. GitHub #54. - Add
IsResidentialProxyfield toAnonymousIP. Pull request by Brendan Boyle. GitHub #72. - Support DBIP-ASN-Lite database. Requested by Muhammad Hussein Fattahizadeh. GitHub #69.
- This module now uses Go modules. Requested by Axel Etcheverry. GitHub #52.
- DBIP databases are now supported. Requested by jaw0. GitHub #45.
- Allow using the ASN method with the GeoIP2 ISP database. Pull request by lspgn. GitHub #47.
- The example in the
README.mdnow checks the length of the subdivision slice before using it. GitHub #51.
- Added support for the GeoIP2 Enterprise database.
- HTTPS is now used for the test data submodule rather than the Git protocol
- The country structs for
geoip2.Cityandgeoip2.Countrynow have anIsInEuropeanUnionboolean field. This is true when the associated country is a member state of the European Union. This requires a database built on or after February 13, 2018. - Switch from Go Check to Testify. Closes #27
- Add support for the GeoLite2 ASN database.
- Add support for the GeoIP2 City by Continent databases. GitHub #26.
New release for those using tagged releases. Closes #21.