geoip2
packagemoduleThis package is not in the latest version of its module.
Details
Validgo.mod file
The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable license
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Tagged version
Modules with tagged versions give importers more predictable builds.
Stable version
When a project reaches major version v1 it is considered stable.
- Learn more about best practices
Repository
Links
README¶
GeoIP2 Reader for Go
This library reads MaxMindGeoLite2 andGeoIP2 databases.
This library is built usingthe Go maxminddb reader. Alldata for the database record is decoded using this library. Version 2.0provides significant performance improvements with 56% fewer allocations and34% less memory usage compared to v1. Version 2.0 also addsNetwork andIPAddress fields to all result structs, and includes aHasData() method toeasily check if data was found. If you only need several fields, you may getsuperior performance by using maxminddb'sLookup directly with a resultstruct that only contains the required fields. (Seeexample_test.goin the maxminddb repository for an example of this.)
Installation
go get github.com/oschwald/geoip2-golang/v2New in v2
Version 2.0 includes several major improvements:
- Performance: 56% fewer allocations and 34% less memory usage
- Modern API: Uses
netip.Addrinstead ofnet.IPfor better performance - Network Information: All result structs now include
NetworkandIPAddressfields - Data Validation: New
HasData()method to easily check if data was found - Structured Names: Replaced
map[string]stringwith typedNamesstructfor better performance - Go 1.24 Support: Uses
omitzeroJSON tags to match MaxMind databasebehavior
Migration
SeeMIGRATION.md for step-by-step guidance on upgrading fromv1.
Usage
See GoDoc fordocumentation and examples.
Example
package mainimport ("fmt""log""net/netip""github.com/oschwald/geoip2-golang/v2")func main() {db, err := geoip2.Open("GeoIP2-City.mmdb")if err != nil {log.Fatal(err)}defer db.Close()// If you are using strings that may be invalid, use netip.ParseAddr and check for errorsip, err := netip.ParseAddr("81.2.69.142")if err != nil {log.Fatal(err)}record, err := db.City(ip)if err != nil {log.Fatal(err)}if !record.HasData() {fmt.Println("No data found for this IP")return}fmt.Printf("Portuguese (BR) city name: %v\n", record.City.Names.BrazilianPortuguese)if len(record.Subdivisions) > 0 {fmt.Printf("English subdivision name: %v\n", record.Subdivisions[0].Names.English)}fmt.Printf("Russian country name: %v\n", record.Country.Names.Russian)fmt.Printf("ISO country code: %v\n", record.Country.ISOCode)fmt.Printf("Time zone: %v\n", record.Location.TimeZone)if record.Location.HasCoordinates() {fmt.Printf("Coordinates: %v, %v\n", *record.Location.Latitude, *record.Location.Longitude)}// Output:// Portuguese (BR) city name: Londres// English subdivision name: England// Russian country name: Великобритания// ISO country code: GB// Time zone: Europe/London// Coordinates: 51.5142, -0.0931}Requirements
- Go 1.24 or later
- MaxMind GeoIP2 or GeoLite2 database files (.mmdb format)
Getting Database Files
GeoLite2 (Free)
Download free GeoLite2 databases fromMaxMind's website.Registration required.
GeoIP2 (Commercial)
Purchase GeoIP2 databases fromMaxMind for enhanced accuracyand additional features.
Database Examples
This library supports all MaxMind GeoIP2 and GeoLite2 database types. Below areexamples for each database type:
City Database
The City database provides the most comprehensive geolocation data, includingcity, subdivision, country, and precise location information.
package mainimport ("fmt""log""net/netip""github.com/oschwald/geoip2-golang/v2")func main() {db, err := geoip2.Open("GeoIP2-City.mmdb")if err != nil {log.Fatal(err)}defer db.Close()ip, err := netip.ParseAddr("128.101.101.101")if err != nil {log.Fatal(err)}record, err := db.City(ip)if err != nil {log.Fatal(err)}if !record.HasData() {fmt.Println("No data found for this IP")return}fmt.Printf("City: %v\n", record.City.Names.English)fmt.Printf("Subdivision: %v\n", record.Subdivisions[0].Names.English)fmt.Printf("Country: %v (%v)\n", record.Country.Names.English, record.Country.ISOCode)fmt.Printf("Continent: %v (%v)\n", record.Continent.Names.English, record.Continent.Code)fmt.Printf("Postal Code: %v\n", record.Postal.Code)if record.Location.HasCoordinates() {fmt.Printf("Location: %v, %v\n", *record.Location.Latitude, *record.Location.Longitude)}fmt.Printf("Time Zone: %v\n", record.Location.TimeZone)fmt.Printf("Network: %v\n", record.Traits.Network)fmt.Printf("IP Address: %v\n", record.Traits.IPAddress)}Country Database
The Country database provides country-level geolocation data.
package mainimport ("fmt""log""net/netip""github.com/oschwald/geoip2-golang/v2")func main() {db, err := geoip2.Open("GeoIP2-Country.mmdb")if err != nil {log.Fatal(err)}defer db.Close()ip, err := netip.ParseAddr("81.2.69.142")if err != nil {log.Fatal(err)}record, err := db.Country(ip)if err != nil {log.Fatal(err)}if !record.HasData() {fmt.Println("No data found for this IP")return}fmt.Printf("Country: %v (%v)\n", record.Country.Names.English, record.Country.ISOCode)fmt.Printf("Continent: %v (%v)\n", record.Continent.Names.English, record.Continent.Code)fmt.Printf("Is in EU: %v\n", record.Country.IsInEuropeanUnion)fmt.Printf("Network: %v\n", record.Traits.Network)fmt.Printf("IP Address: %v\n", record.Traits.IPAddress)if record.RegisteredCountry.Names.English != "" {fmt.Printf("Registered Country: %v (%v)\n",record.RegisteredCountry.Names.English, record.RegisteredCountry.ISOCode)}}ASN Database
The ASN database provides Autonomous System Number and organizationinformation.
package mainimport ("fmt""log""net/netip""github.com/oschwald/geoip2-golang/v2")func main() {db, err := geoip2.Open("GeoLite2-ASN.mmdb")if err != nil {log.Fatal(err)}defer db.Close()ip, err := netip.ParseAddr("1.128.0.0")if err != nil {log.Fatal(err)}record, err := db.ASN(ip)if err != nil {log.Fatal(err)}if !record.HasData() {fmt.Println("No data found for this IP")return}fmt.Printf("ASN: %v\n", record.AutonomousSystemNumber)fmt.Printf("Organization: %v\n", record.AutonomousSystemOrganization)fmt.Printf("Network: %v\n", record.Network)fmt.Printf("IP Address: %v\n", record.IPAddress)}Anonymous IP Database
The Anonymous IP database identifies various types of anonymous and proxynetworks.
package mainimport ("fmt""log""net/netip""github.com/oschwald/geoip2-golang/v2")func main() {db, err := geoip2.Open("GeoIP2-Anonymous-IP.mmdb")if err != nil {log.Fatal(err)}defer db.Close()ip, err := netip.ParseAddr("81.2.69.142")if err != nil {log.Fatal(err)}record, err := db.AnonymousIP(ip)if err != nil {log.Fatal(err)}if !record.HasData() {fmt.Println("No data found for this IP")return}fmt.Printf("Is Anonymous: %v\n", record.IsAnonymous)fmt.Printf("Is Anonymous VPN: %v\n", record.IsAnonymousVPN)fmt.Printf("Is Hosting Provider: %v\n", record.IsHostingProvider)fmt.Printf("Is Public Proxy: %v\n", record.IsPublicProxy)fmt.Printf("Is Residential Proxy: %v\n", record.IsResidentialProxy)fmt.Printf("Is Tor Exit Node: %v\n", record.IsTorExitNode)fmt.Printf("Network: %v\n", record.Network)fmt.Printf("IP Address: %v\n", record.IPAddress)}Enterprise Database
The Enterprise database provides the most comprehensive data, including allCity database fields plus additional enterprise features.
package mainimport ("fmt""log""net/netip""github.com/oschwald/geoip2-golang/v2")func main() {db, err := geoip2.Open("GeoIP2-Enterprise.mmdb")if err != nil {log.Fatal(err)}defer db.Close()ip, err := netip.ParseAddr("128.101.101.101")if err != nil {log.Fatal(err)}record, err := db.Enterprise(ip)if err != nil {log.Fatal(err)}if !record.HasData() {fmt.Println("No data found for this IP")return}// Basic location informationfmt.Printf("City: %v\n", record.City.Names.English)fmt.Printf("Country: %v (%v)\n", record.Country.Names.English, record.Country.ISOCode)if record.Location.HasCoordinates() {fmt.Printf("Location: %v, %v\n", *record.Location.Latitude, *record.Location.Longitude)}// Enterprise-specific fieldsfmt.Printf("ISP: %v\n", record.Traits.ISP)fmt.Printf("Organization: %v\n", record.Traits.Organization)fmt.Printf("ASN: %v (%v)\n", record.Traits.AutonomousSystemNumber,record.Traits.AutonomousSystemOrganization)fmt.Printf("Connection Type: %v\n", record.Traits.ConnectionType)fmt.Printf("Domain: %v\n", record.Traits.Domain)fmt.Printf("User Type: %v\n", record.Traits.UserType)fmt.Printf("Static IP Score: %v\n", record.Traits.StaticIPScore)fmt.Printf("Is Anycast: %v\n", record.Traits.IsAnycast)fmt.Printf("Is Legitimate Proxy: %v\n", record.Traits.IsLegitimateProxy)// Mobile carrier information (if available)if record.Traits.MobileCountryCode != "" {fmt.Printf("Mobile Country Code: %v\n", record.Traits.MobileCountryCode)fmt.Printf("Mobile Network Code: %v\n", record.Traits.MobileNetworkCode)}fmt.Printf("Network: %v\n", record.Traits.Network)fmt.Printf("IP Address: %v\n", record.Traits.IPAddress)}ISP Database
The ISP database provides ISP, organization, and ASN information.
package mainimport ("fmt""log""net/netip""github.com/oschwald/geoip2-golang/v2")func main() {db, err := geoip2.Open("GeoIP2-ISP.mmdb")if err != nil {log.Fatal(err)}defer db.Close()ip, err := netip.ParseAddr("1.128.0.0")if err != nil {log.Fatal(err)}record, err := db.ISP(ip)if err != nil {log.Fatal(err)}if !record.HasData() {fmt.Println("No data found for this IP")return}fmt.Printf("ISP: %v\n", record.ISP)fmt.Printf("Organization: %v\n", record.Organization)fmt.Printf("ASN: %v (%v)\n", record.AutonomousSystemNumber,record.AutonomousSystemOrganization)// Mobile carrier information (if available)if record.MobileCountryCode != "" {fmt.Printf("Mobile Country Code: %v\n", record.MobileCountryCode)fmt.Printf("Mobile Network Code: %v\n", record.MobileNetworkCode)}fmt.Printf("Network: %v\n", record.Network)fmt.Printf("IP Address: %v\n", record.IPAddress)}Domain Database
The Domain database provides the second-level domain associated with an IPaddress.
package mainimport ("fmt""log""net/netip""github.com/oschwald/geoip2-golang/v2")func main() {db, err := geoip2.Open("GeoIP2-Domain.mmdb")if err != nil {log.Fatal(err)}defer db.Close()ip, err := netip.ParseAddr("1.2.0.0")if err != nil {log.Fatal(err)}record, err := db.Domain(ip)if err != nil {log.Fatal(err)}if !record.HasData() {fmt.Println("No data found for this IP")return}fmt.Printf("Domain: %v\n", record.Domain)fmt.Printf("Network: %v\n", record.Network)fmt.Printf("IP Address: %v\n", record.IPAddress)}Connection Type Database
The Connection Type database identifies the connection type of an IP address.
package mainimport ("fmt""log""net/netip""github.com/oschwald/geoip2-golang/v2")func main() {db, err := geoip2.Open("GeoIP2-Connection-Type.mmdb")if err != nil {log.Fatal(err)}defer db.Close()ip, err := netip.ParseAddr("1.0.128.0")if err != nil {log.Fatal(err)}record, err := db.ConnectionType(ip)if err != nil {log.Fatal(err)}if !record.HasData() {fmt.Println("No data found for this IP")return}fmt.Printf("Connection Type: %v\n", record.ConnectionType)fmt.Printf("Network: %v\n", record.Network)fmt.Printf("IP Address: %v\n", record.IPAddress)}Error Handling
All database lookups can return errors and should be handled appropriately:
package mainimport ("fmt""log""net/netip""github.com/oschwald/geoip2-golang/v2")func main() {db, err := geoip2.Open("GeoIP2-City.mmdb")if err != nil {log.Fatal(err)}defer db.Close()ip, err := netip.ParseAddr("10.0.0.1") // Private IPif err != nil {log.Fatal(err)}record, err := db.City(ip)if err != nil {log.Fatal(err)}// Always check if data was foundif !record.HasData() {fmt.Println("No data found for this IP address")return}// Check individual fields before using themif record.City.Names.English != "" {fmt.Printf("City: %v\n", record.City.Names.English)} else {fmt.Println("City name not available")}// Check array bounds for subdivisionsif len(record.Subdivisions) > 0 {fmt.Printf("Subdivision: %v\n", record.Subdivisions[0].Names.English)} else {fmt.Println("No subdivision data available")}fmt.Printf("Country: %v\n", record.Country.Names.English)}Performance Tips
Database Reuse
Always reuse database instances across requests rather than opening/closingrepeatedly:
// Good: Create once, use many timesdb, err := geoip2.Open("GeoIP2-City.mmdb")if err != nil { log.Fatal(err)}defer db.Close()// Use db for multiple lookups...Memory Usage
For applications needing only specific fields, consider using the lower-levelmaxminddb library with custom result structs to reduce memory allocation.
Concurrent Usage
The Reader is safe for concurrent use by multiple goroutines.
JSON Serialization
All result structs include JSON tags and support marshaling to JSON:
record, err := db.City(ip)if err != nil { log.Fatal(err)}jsonData, err := json.Marshal(record)if err != nil { log.Fatal(err)}fmt.Println(string(jsonData))Migration from v1
Breaking Changes
- Import Path: Change from
github.com/oschwald/geoip2-golangtogithub.com/oschwald/geoip2-golang/v2 - IP Type: Use
netip.Addrinstead ofnet.IP - Field Names:
IsoCode→ISOCode - Names Access: Use struct fields instead of map access
- Data Validation: Use
HasData()method to check for data availability
Migration Example
// v1import "github.com/oschwald/geoip2-golang"ip := net.ParseIP("81.2.69.142")record, err := db.City(ip)cityName := record.City.Names["en"]// v2import "github.com/oschwald/geoip2-golang/v2"ip, err := netip.ParseAddr("81.2.69.142")if err != nil { // handle error}record, err := db.City(ip)if !record.HasData() { // handle no data found}cityName := record.City.Names.EnglishTroubleshooting
Common Issues
Database not found: Ensure the .mmdb file path is correct and readable.
No data returned: Check ifHasData() returns false - the IP may not be inthe database or may be a private/reserved IP.
Performance issues: Ensure you're reusing the database instance rather thanopening it for each lookup.
Testing
Make sure you checked out test data submodule:
git submodule initgit submodule updateExecute test suite:
go testContributing
Contributions welcome! Please fork the repository and open a pull request withyour changes.
License
This is free software, licensed under the ISC license.
Documentation¶
Overview¶
Package geoip2 provides an easy-to-use API for the MaxMind GeoIP2 andGeoLite2 databases; this package does not support GeoIP Legacy databases.
Basic Usage¶
db, err := geoip2.Open("GeoIP2-City.mmdb")if err != nil {log.Fatal(err)}defer db.Close()ip, err := netip.ParseAddr("81.2.69.142")if err != nil {log.Fatal(err)}record, err := db.City(ip)if err != nil {log.Fatal(err)}if !record.HasData() {fmt.Println("No data found for this IP")return}fmt.Printf("City: %v\n", record.City.Names.English)fmt.Printf("Country: %v\n", record.Country.Names.English)Database Types¶
This library supports all MaxMind database types:
- City: Most comprehensive geolocation data
- Country: Country-level geolocation
- ASN: Autonomous system information
- AnonymousIP: Anonymous network detection
- Enterprise: Enhanced City data with additional fields
- ISP: Internet service provider information
- Domain: Second-level domain data
- ConnectionType: Connection type identification
Version 2.0 Features¶
Version 2.0 introduces significant improvements:
- Modern API using netip.Addr instead of net.IP
- Network and IPAddress fields in all result structs
- HasData() method for data validation
- Structured Names type for localized names
- JSON serialization support
See github.com/oschwald/maxminddb-golang/v2 for more advanced use cases.
Example¶
Example provides a basic example of using the API. Use of the Countrymethod is analogous to that of the City method.
db, err := Open("test-data/test-data/GeoIP2-City-Test.mmdb")if err != nil {log.Panic(err)}defer db.Close()// If you are using strings that may be invalid, use netip.ParseAddr and check for errorsip, err := netip.ParseAddr("81.2.69.142")if err != nil {log.Panic(err)}record, err := db.City(ip)if err != nil {log.Panic(err)}fmt.Printf("Portuguese (BR) city name: %v\n", record.City.Names.BrazilianPortuguese)fmt.Printf("English subdivision name: %v\n", record.Subdivisions[0].Names.English)fmt.Printf("Russian country name: %v\n", record.Country.Names.Russian)fmt.Printf("ISO country code: %v\n", record.Country.ISOCode)fmt.Printf("Time zone: %v\n", record.Location.TimeZone)if record.Location.HasCoordinates() {fmt.Printf("Coordinates: %v, %v\n", *record.Location.Latitude, *record.Location.Longitude)} else {fmt.Println("Coordinates: unavailable")}Output:Portuguese (BR) city name: LondresEnglish subdivision name: EnglandRussian country name: ВеликобританияISO country code: GBTime zone: Europe/LondonCoordinates: 51.5142, -0.0931
Index¶
- type ASN
- type AnonymousIP
- type City
- type CityPostal
- type CityRecord
- type CitySubdivision
- type CityTraits
- type ConnectionType
- type Continent
- type Country
- type CountryRecord
- type CountryTraits
- type Domain
- type Enterprise
- type EnterpriseCityRecord
- type EnterpriseCountryRecord
- type EnterprisePostal
- type EnterpriseSubdivision
- type EnterpriseTraits
- type ISP
- type InvalidMethodError
- type Location
- type Names
- type Option
- type Reader
- func (r *Reader) ASN(ipAddress netip.Addr) (*ASN, error)
- func (r *Reader) AnonymousIP(ipAddress netip.Addr) (*AnonymousIP, error)
- func (r *Reader) City(ipAddress netip.Addr) (*City, error)
- func (r *Reader) Close() error
- func (r *Reader) ConnectionType(ipAddress netip.Addr) (*ConnectionType, error)
- func (r *Reader) Country(ipAddress netip.Addr) (*Country, error)
- func (r *Reader) Domain(ipAddress netip.Addr) (*Domain, error)
- func (r *Reader) Enterprise(ipAddress netip.Addr) (*Enterprise, error)
- func (r *Reader) ISP(ipAddress netip.Addr) (*ISP, error)
- func (r *Reader) Metadata() maxminddb.Metadata
- type RepresentedCountry
- type UnknownDatabaseTypeError
Examples¶
Constants¶
This section is empty.
Variables¶
This section is empty.
Functions¶
This section is empty.
Types¶
typeASN¶
type ASN struct {// IPAddress is the IP address used during the lookupIPAddressnetip.Addr `json:"ip_address,omitzero"`// Network is the largest network prefix where all fields besides// IPAddress have the same value.Networknetip.Prefix `json:"network,omitzero"`// AutonomousSystemOrganization for the registered autonomous system number.AutonomousSystemOrganizationstring `json:"autonomous_system_organization,omitzero" maxminddb:"autonomous_system_organization"`//nolint:lll// AutonomousSystemNumber for the IP address.AutonomousSystemNumberuint `json:"autonomous_system_number,omitzero" maxminddb:"autonomous_system_number"`//nolint:lll}The ASN struct corresponds to the data in the GeoLite2 ASN database.
typeAnonymousIP¶
type AnonymousIP struct {// IPAddress is the IP address used during the lookupIPAddressnetip.Addr `json:"ip_address,omitzero"`// Network is the largest network prefix where all fields besides// IPAddress have the same value.Networknetip.Prefix `json:"network,omitzero"`// IsAnonymous is true if the IP address belongs to any sort of anonymous network.IsAnonymousbool `json:"is_anonymous,omitzero" maxminddb:"is_anonymous"`// IsAnonymousVPN is true if the IP address is registered to an anonymous// VPN provider. If a VPN provider does not register subnets under names// associated with them, we will likely only flag their IP ranges using the// IsHostingProvider attribute.IsAnonymousVPNbool `json:"is_anonymous_vpn,omitzero" maxminddb:"is_anonymous_vpn"`// IsHostingProvider is true if the IP address belongs to a hosting or VPN provider// (see description of IsAnonymousVPN attribute).IsHostingProviderbool `json:"is_hosting_provider,omitzero" maxminddb:"is_hosting_provider"`// IsPublicProxy is true if the IP address belongs to a public proxy.IsPublicProxybool `json:"is_public_proxy,omitzero" maxminddb:"is_public_proxy"`// IsResidentialProxy is true if the IP address is on a suspected// anonymizing network and belongs to a residential ISP.IsResidentialProxybool `json:"is_residential_proxy,omitzero" maxminddb:"is_residential_proxy"`// IsTorExitNode is true if the IP address is a Tor exit node.IsTorExitNodebool `json:"is_tor_exit_node,omitzero" maxminddb:"is_tor_exit_node"`}The AnonymousIP struct corresponds to the data in the GeoIP2Anonymous IP database.
func (AnonymousIP)HasData¶
func (aAnonymousIP) HasData()bool
HasData returns true if any data was found for the IP in the AnonymousIP database.This excludes the Network and IPAddress fields which are always populated for found IPs.
typeCity¶
type City struct {// Traits contains various traits associated with the IP addressTraitsCityTraits `json:"traits,omitzero" maxminddb:"traits"`// Postal contains data for the postal record associated with the IP addressPostalCityPostal `json:"postal,omitzero" maxminddb:"postal"`// Continent contains data for the continent record associated with the IP addressContinentContinent `json:"continent,omitzero" maxminddb:"continent"`// City contains data for the city record associated with the IP addressCityCityRecord `json:"city,omitzero" maxminddb:"city"`// Subdivisions contains data for the subdivisions associated with the IP// address. The subdivisions array is ordered from largest to smallest. For// instance, the response for Oxford in the United Kingdom would have England// as the first element and Oxfordshire as the second element.Subdivisions []CitySubdivision `json:"subdivisions,omitzero" maxminddb:"subdivisions"`// RepresentedCountry contains data for the represented country associated// with the IP address. The represented country is the country represented// by something like a military base or embassy.RepresentedCountryRepresentedCountry `json:"represented_country,omitzero" maxminddb:"represented_country"`// Country contains data for the country record associated with the IP// address. This record represents the country where MaxMind believes the IP// is located.CountryCountryRecord `json:"country,omitzero" maxminddb:"country"`// RegisteredCountry contains data for the registered country associated// with the IP address. This record represents the country where the ISP has// registered the IP block and may differ from the user's country.RegisteredCountryCountryRecord `json:"registered_country,omitzero" maxminddb:"registered_country"`// Location contains data for the location record associated with the IP// addressLocationLocation `json:"location,omitzero" maxminddb:"location"`}The City struct corresponds to the data in the GeoIP2/GeoLite2 Citydatabases.
typeCityPostal¶
type CityPostal struct {// Code is the postal code of the location. Postal codes are not// available for all countries.// In some countries, this will only contain part of the postal code.Codestring `json:"code,omitzero" maxminddb:"code"`}CityPostal contains postal data for City database records.
func (CityPostal)HasData¶
func (pCityPostal) HasData()bool
HasData returns true if the CityPostal has any data.
typeCityRecord¶
type CityRecord struct {// Names contains localized names for the cityNamesNames `json:"names,omitzero" maxminddb:"names"`// GeoNameID for the cityGeoNameIDuint `json:"geoname_id,omitzero" maxminddb:"geoname_id"`}CityRecord contains city data for City database records.
func (CityRecord)HasData¶
func (cCityRecord) HasData()bool
HasData returns true if the CityRecord has any data.
typeCitySubdivision¶
type CitySubdivision struct {NamesNames `json:"names,omitzero" maxminddb:"names"`ISOCodestring `json:"iso_code,omitzero" maxminddb:"iso_code"`GeoNameIDuint `json:"geoname_id,omitzero" maxminddb:"geoname_id"`}CitySubdivision contains subdivision data for City database records.
func (CitySubdivision)HasData¶
func (sCitySubdivision) HasData()bool
HasData returns true if the CitySubdivision has any data.
typeCityTraits¶
type CityTraits struct {// IPAddress is the IP address used during the lookupIPAddressnetip.Addr `json:"ip_address,omitzero"`// Network is the network prefix for this record. This is the largest// network where all of the fields besides IPAddress have the same value.Networknetip.Prefix `json:"network,omitzero"`// IsAnycast is true if the IP address belongs to an anycast network.// Seehttps://en.wikipedia.org/wiki/AnycastIsAnycastbool `json:"is_anycast,omitzero" maxminddb:"is_anycast"`}CityTraits contains traits data for City database records.
func (CityTraits)HasData¶
func (tCityTraits) HasData()bool
HasData returns true if the CityTraits has any data (excluding Network and IPAddress).
typeConnectionType¶
type ConnectionType struct {// ConnectionType indicates the connection type. May be Dialup, Cable/DSL,// Corporate, Cellular, or Satellite. Additional values may be added in the// future.ConnectionTypestring `json:"connection_type,omitzero" maxminddb:"connection_type"`// IPAddress is the IP address used during the lookupIPAddressnetip.Addr `json:"ip_address,omitzero"`// Network is the largest network prefix where all fields besides// IPAddress have the same value.Networknetip.Prefix `json:"network,omitzero"`}The ConnectionType struct corresponds to the data in the GeoIP2Connection-Type database.
func (ConnectionType)HasData¶
func (cConnectionType) HasData()bool
HasData returns true if any data was found for the IP in the ConnectionType database.This excludes the Network and IPAddress fields which are always populated for found IPs.
typeContinent¶
type Continent struct {// Names contains localized names for the continentNamesNames `json:"names,omitzero" maxminddb:"names"`// Code is a two character continent code like "NA" (North America) or// "OC" (Oceania)Codestring `json:"code,omitzero" maxminddb:"code"`// GeoNameID for the continentGeoNameIDuint `json:"geoname_id,omitzero" maxminddb:"geoname_id"`}Continent contains data for the continent record associated with an IP address.
typeCountry¶
type Country struct {// Traits contains various traits associated with the IP addressTraitsCountryTraits `json:"traits,omitzero" maxminddb:"traits"`// Continent contains data for the continent record associated with the IP addressContinentContinent `json:"continent,omitzero" maxminddb:"continent"`// RepresentedCountry contains data for the represented country associated// with the IP address. The represented country is the country represented// by something like a military base or embassy.RepresentedCountryRepresentedCountry `json:"represented_country,omitzero" maxminddb:"represented_country"`// Country contains data for the country record associated with the IP// address. This record represents the country where MaxMind believes the IP// is located.CountryCountryRecord `json:"country,omitzero" maxminddb:"country"`// RegisteredCountry contains data for the registered country associated// with the IP address. This record represents the country where the ISP has// registered the IP block and may differ from the user's country.RegisteredCountryCountryRecord `json:"registered_country,omitzero" maxminddb:"registered_country"`}The Country struct corresponds to the data in the GeoIP2/GeoLite2Country databases.
typeCountryRecord¶
type CountryRecord struct {// Names contains localized names for the countryNamesNames `json:"names,omitzero" maxminddb:"names"`// ISOCode is the two-character ISO 3166-1 alpha code for the country.// Seehttps://en.wikipedia.org/wiki/ISO_3166-1_alpha-2ISOCodestring `json:"iso_code,omitzero" maxminddb:"iso_code"`// GeoNameID for the countryGeoNameIDuint `json:"geoname_id,omitzero" maxminddb:"geoname_id"`// IsInEuropeanUnion is true if the country is a member state of the// European UnionIsInEuropeanUnionbool `json:"is_in_european_union,omitzero" maxminddb:"is_in_european_union"`}CountryRecord contains country data for City and Country database records.
func (CountryRecord)HasData¶
func (cCountryRecord) HasData()bool
HasData returns true if the CountryRecord has any data.
typeCountryTraits¶
type CountryTraits struct {// IPAddress is the IP address used during the lookupIPAddressnetip.Addr `json:"ip_address,omitzero"`// Network is the largest network prefix where all fields besides// IPAddress have the same value.Networknetip.Prefix `json:"network,omitzero"`// IsAnycast is true if the IP address belongs to an anycast network.// Seehttps://en.wikipedia.org/wiki/AnycastIsAnycastbool `json:"is_anycast,omitzero" maxminddb:"is_anycast"`}CountryTraits contains traits data for Country database records.
func (CountryTraits)HasData¶
func (tCountryTraits) HasData()bool
HasData returns true if the CountryTraits has any data (excluding Network and IPAddress).
typeDomain¶
type Domain struct {// Domain is the second level domain associated with the IP address// (e.g., "example.com")Domainstring `json:"domain,omitzero" maxminddb:"domain"`// IPAddress is the IP address used during the lookupIPAddressnetip.Addr `json:"ip_address,omitzero"`// Network is the largest network prefix where all fields besides// IPAddress have the same value.Networknetip.Prefix `json:"network,omitzero"`}The Domain struct corresponds to the data in the GeoIP2 Domain database.
typeEnterprise¶
type Enterprise struct {// Continent contains data for the continent record associated with the IP// address.ContinentContinent `json:"continent,omitzero" maxminddb:"continent"`// Subdivisions contains data for the subdivisions associated with the IP// address. The subdivisions array is ordered from largest to smallest. For// instance, the response for Oxford in the United Kingdom would have England// as the first element and Oxfordshire as the second element.Subdivisions []EnterpriseSubdivision `json:"subdivisions,omitzero" maxminddb:"subdivisions"`// Postal contains data for the postal record associated with the IP address.PostalEnterprisePostal `json:"postal,omitzero" maxminddb:"postal"`// RepresentedCountry contains data for the represented country associated// with the IP address. The represented country is the country represented// by something like a military base or embassy.RepresentedCountryRepresentedCountry `json:"represented_country,omitzero" maxminddb:"represented_country"`// Country contains data for the country record associated with the IP// address. This record represents the country where MaxMind believes the IP// is located.CountryEnterpriseCountryRecord `json:"country,omitzero" maxminddb:"country"`// RegisteredCountry contains data for the registered country associated// with the IP address. This record represents the country where the ISP has// registered the IP block and may differ from the user's country.RegisteredCountryCountryRecord `json:"registered_country,omitzero" maxminddb:"registered_country"`// City contains data for the city record associated with the IP address.CityEnterpriseCityRecord `json:"city,omitzero" maxminddb:"city"`// Location contains data for the location record associated with the IP// addressLocationLocation `json:"location,omitzero" maxminddb:"location"`// Traits contains various traits associated with the IP addressTraitsEnterpriseTraits `json:"traits,omitzero" maxminddb:"traits"`}The Enterprise struct corresponds to the data in the GeoIP2 Enterprisedatabase.
func (Enterprise)HasData¶
func (eEnterprise) HasData()bool
HasData returns true if any GeoIP data was found for the IP in the Enterprise database.This excludes the Network and IPAddress fields which are always populated for found IPs.
typeEnterpriseCityRecord¶
type EnterpriseCityRecord struct {// Names contains localized names for the cityNamesNames `json:"names,omitzero" maxminddb:"names"`// GeoNameID for the cityGeoNameIDuint `json:"geoname_id,omitzero" maxminddb:"geoname_id"`// Confidence is a value from 0-100 indicating MaxMind's confidence that// the city is correctConfidenceuint8 `json:"confidence,omitzero" maxminddb:"confidence"`}EnterpriseCityRecord contains city data for Enterprise database records.
func (EnterpriseCityRecord)HasData¶
func (cEnterpriseCityRecord) HasData()bool
HasData returns true if the EnterpriseCityRecord has any data.
typeEnterpriseCountryRecord¶
type EnterpriseCountryRecord struct {// Names contains localized names for the countryNamesNames `json:"names,omitzero" maxminddb:"names"`// ISOCode is the two-character ISO 3166-1 alpha code for the country.// Seehttps://en.wikipedia.org/wiki/ISO_3166-1_alpha-2ISOCodestring `json:"iso_code,omitzero" maxminddb:"iso_code"`// GeoNameID for the countryGeoNameIDuint `json:"geoname_id,omitzero" maxminddb:"geoname_id"`// Confidence is a value from 0-100 indicating MaxMind's confidence that// the country is correctConfidenceuint8 `json:"confidence,omitzero" maxminddb:"confidence"`// IsInEuropeanUnion is true if the country is a member state of the// European UnionIsInEuropeanUnionbool `json:"is_in_european_union,omitzero" maxminddb:"is_in_european_union"`}EnterpriseCountryRecord contains country data for Enterprise database records.
func (EnterpriseCountryRecord)HasData¶
func (cEnterpriseCountryRecord) HasData()bool
HasData returns true if the EnterpriseCountryRecord has any data.
typeEnterprisePostal¶
type EnterprisePostal struct {// Code is the postal code of the location. Postal codes are not// available for all countries.// In some countries, this will only contain part of the postal code.Codestring `json:"code,omitzero" maxminddb:"code"`// Confidence is a value from 0-100 indicating MaxMind's confidence that// the postal code is correctConfidenceuint8 `json:"confidence,omitzero" maxminddb:"confidence"`}EnterprisePostal contains postal data for Enterprise database records.
func (EnterprisePostal)HasData¶
func (pEnterprisePostal) HasData()bool
HasData returns true if the EnterprisePostal has any data.
typeEnterpriseSubdivision¶
type EnterpriseSubdivision struct {// Names contains localized names for the subdivisionNamesNames `json:"names,omitzero" maxminddb:"names"`// ISOCode is a string up to three characters long containing the// subdivision portion of the ISO 3166-2 code.// Seehttps://en.wikipedia.org/wiki/ISO_3166-2ISOCodestring `json:"iso_code,omitzero" maxminddb:"iso_code"`// GeoNameID for the subdivisionGeoNameIDuint `json:"geoname_id,omitzero" maxminddb:"geoname_id"`// Confidence is a value from 0-100 indicating MaxMind's confidence that// the subdivision is correctConfidenceuint8 `json:"confidence,omitzero" maxminddb:"confidence"`}EnterpriseSubdivision contains subdivision data for Enterprise database records.
func (EnterpriseSubdivision)HasData¶
func (sEnterpriseSubdivision) HasData()bool
HasData returns true if the EnterpriseSubdivision has any data.
typeEnterpriseTraits¶
type EnterpriseTraits struct {// Network is the largest network prefix where all fields besides// IPAddress have the same value.Networknetip.Prefix `json:"network,omitzero"`// IPAddress is the IP address used during the lookupIPAddressnetip.Addr `json:"ip_address,omitzero"`// AutonomousSystemOrganization for the registered ASNAutonomousSystemOrganizationstring `json:"autonomous_system_organization,omitzero" maxminddb:"autonomous_system_organization"`//nolint:lll// ConnectionType indicates the connection type. May be Dialup,// Cable/DSL, Corporate, Cellular, or SatelliteConnectionTypestring `json:"connection_type,omitzero" maxminddb:"connection_type"`// Domain is the second level domain associated with the IP address// (e.g., "example.com")Domainstring `json:"domain,omitzero" maxminddb:"domain"`// ISP is the name of the ISP associated with the IP addressISPstring `json:"isp,omitzero" maxminddb:"isp"`// MobileCountryCode is the mobile country code (MCC) associated with// the IP address and ISP.// Seehttps://en.wikipedia.org/wiki/Mobile_country_codeMobileCountryCodestring `json:"mobile_country_code,omitzero" maxminddb:"mobile_country_code"`// MobileNetworkCode is the mobile network code (MNC) associated with// the IP address and ISP.// Seehttps://en.wikipedia.org/wiki/Mobile_network_codeMobileNetworkCodestring `json:"mobile_network_code,omitzero" maxminddb:"mobile_network_code"`// Organization is the name of the organization associated with the IP// addressOrganizationstring `json:"organization,omitzero" maxminddb:"organization"`// UserType indicates the user type associated with the IP address// (business, cafe, cellular, college, etc.)UserTypestring `json:"user_type,omitzero" maxminddb:"user_type"`// StaticIPScore is an indicator of how static or dynamic an IP address// is, ranging from 0 to 99.99StaticIPScorefloat64 `json:"static_ip_score,omitzero" maxminddb:"static_ip_score"`// AutonomousSystemNumber for the IP addressAutonomousSystemNumberuint `json:"autonomous_system_number,omitzero" maxminddb:"autonomous_system_number"`// IsAnycast is true if the IP address belongs to an anycast network.// Seehttps://en.wikipedia.org/wiki/AnycastIsAnycastbool `json:"is_anycast,omitzero" maxminddb:"is_anycast"`// IsLegitimateProxy is true if MaxMind believes this IP address to be a// legitimate proxy, such as an internal VPN used by a corporationIsLegitimateProxybool `json:"is_legitimate_proxy,omitzero" maxminddb:"is_legitimate_proxy"`}EnterpriseTraits contains traits data for Enterprise database records.
func (EnterpriseTraits)HasData¶
func (tEnterpriseTraits) HasData()bool
HasData returns true if the EnterpriseTraits has any data (excluding Network and IPAddress).
typeISP¶
type ISP struct {// Network is the largest network prefix where all fields besides// IPAddress have the same value.Networknetip.Prefix `json:"network,omitzero"`// IPAddress is the IP address used during the lookupIPAddressnetip.Addr `json:"ip_address,omitzero"`// AutonomousSystemOrganization for the registered ASNAutonomousSystemOrganizationstring `json:"autonomous_system_organization,omitzero" maxminddb:"autonomous_system_organization"`//nolint:lll// ISP is the name of the ISP associated with the IP addressISPstring `json:"isp,omitzero" maxminddb:"isp"`// MobileCountryCode is the mobile country code (MCC) associated with the IP address and ISP.// Seehttps://en.wikipedia.org/wiki/Mobile_country_codeMobileCountryCodestring `json:"mobile_country_code,omitzero" maxminddb:"mobile_country_code"`// MobileNetworkCode is the mobile network code (MNC) associated with the IP address and ISP.// Seehttps://en.wikipedia.org/wiki/Mobile_network_codeMobileNetworkCodestring `json:"mobile_network_code,omitzero" maxminddb:"mobile_network_code"`// Organization is the name of the organization associated with the IP addressOrganizationstring `json:"organization,omitzero" maxminddb:"organization"`// AutonomousSystemNumber for the IP addressAutonomousSystemNumberuint `json:"autonomous_system_number,omitzero" maxminddb:"autonomous_system_number"`}The ISP struct corresponds to the data in the GeoIP2 ISP database.
typeInvalidMethodError¶
InvalidMethodError is returned when a lookup method is called on adatabase that it does not support. For instance, calling the ISP methodon a City database.
func (InvalidMethodError)Error¶
func (eInvalidMethodError) Error()string
typeLocation¶
type Location struct {// Latitude is the approximate latitude of the location associated with// the IP address. This value is not precise and should not be used to// identify a particular address or household. Will be nil if not present// in the database.Latitude *float64 `json:"latitude,omitzero" maxminddb:"latitude"`// Longitude is the approximate longitude of the location associated with// the IP address. This value is not precise and should not be used to// identify a particular address or household. Will be nil if not present// in the database.Longitude *float64 `json:"longitude,omitzero" maxminddb:"longitude"`// TimeZone is the time zone associated with location, as specified by// the IANA Time Zone Database (e.g., "America/New_York")TimeZonestring `json:"time_zone,omitzero" maxminddb:"time_zone"`// MetroCode is a metro code for targeting advertisements.//// Deprecated: Metro codes are no longer maintained and should not be used.MetroCodeuint `json:"metro_code,omitzero" maxminddb:"metro_code"`// AccuracyRadius is the approximate accuracy radius in kilometers around// the latitude and longitude. This is the radius where we have a 67%// confidence that the device using the IP address resides within the// circle.AccuracyRadiusuint16 `json:"accuracy_radius,omitzero" maxminddb:"accuracy_radius"`}Location contains data for the location record associated with an IP address.
func (Location)HasCoordinates¶
HasCoordinates returns true if both latitude and longitude are present.
typeNames¶
type Names struct {// German localized nameGermanstring `json:"de,omitzero" maxminddb:"de"`// English localized nameEnglishstring `json:"en,omitzero" maxminddb:"en"`// Spanish localized nameSpanishstring `json:"es,omitzero" maxminddb:"es"`// French localized nameFrenchstring `json:"fr,omitzero" maxminddb:"fr"`// Japanese localized nameJapanesestring `json:"ja,omitzero" maxminddb:"ja"`// BrazilianPortuguese localized name (pt-BR)BrazilianPortuguesestring `json:"pt-BR,omitzero" maxminddb:"pt-BR"`//nolint:tagliatelle,lll // pt-BR matches MMDB format// Russian localized nameRussianstring `json:"ru,omitzero" maxminddb:"ru"`// SimplifiedChinese localized name (zh-CN)SimplifiedChinesestring `json:"zh-CN,omitzero" maxminddb:"zh-CN"`//nolint:tagliatelle // zh-CN matches MMDB format}Names contains localized names for geographic entities.
typeReader¶
type Reader struct {// contains filtered or unexported fields}Reader holds the maxminddb.Reader struct. It can be created using theOpen and OpenBytes functions.
funcOpen¶
Open takes a string path to a file and returns a Reader struct or an error.The database file is opened using a memory map. Use the Close method on theReader object to return the resources to the system.
funcOpenBytes¶
OpenBytes takes a byte slice corresponding to a GeoIP2/GeoLite2 databasefile and returns a Reader struct or an error. Note that the byte slice isused directly; any modification of it after opening the database will resultin errors while reading from the database.
func (*Reader)ASN¶
ASN takes an IP address as a netip.Addr and returns a ASN struct and/oran error.
Example¶
ExampleReader_ASN demonstrates how to use the ASN database.
db, err := Open("test-data/test-data/GeoLite2-ASN-Test.mmdb")if err != nil {log.Panic(err)}defer db.Close()ip, err := netip.ParseAddr("1.128.0.0")if err != nil {log.Panic(err)}record, err := db.ASN(ip)if err != nil {log.Panic(err)}if !record.HasData() {fmt.Println("No data found for this IP")return}fmt.Printf("ASN: %v\n", record.AutonomousSystemNumber)fmt.Printf("Organization: %v\n", record.AutonomousSystemOrganization)Output:ASN: 1221Organization: Telstra Pty Ltd
func (*Reader)AnonymousIP¶
func (r *Reader) AnonymousIP(ipAddressnetip.Addr) (*AnonymousIP,error)
AnonymousIP takes an IP address as a netip.Addr and returns aAnonymousIP struct and/or an error.
Example¶
ExampleReader_AnonymousIP demonstrates how to use the Anonymous IP database.
db, err := Open("test-data/test-data/GeoIP2-Anonymous-IP-Test.mmdb")if err != nil {log.Panic(err)}defer db.Close()ip, err := netip.ParseAddr("1.2.0.0")if err != nil {log.Panic(err)}record, err := db.AnonymousIP(ip)if err != nil {log.Panic(err)}if !record.HasData() {fmt.Println("No data found for this IP")return}fmt.Printf("Is Anonymous: %v\n", record.IsAnonymous)fmt.Printf("Is Anonymous VPN: %v\n", record.IsAnonymousVPN)fmt.Printf("Is Public Proxy: %v\n", record.IsPublicProxy)Output:Is Anonymous: trueIs Anonymous VPN: trueIs Public Proxy: false
func (*Reader)City¶
City takes an IP address as a netip.Addr and returns a City structand/or an error. Although this can be used with other databases, thismethod generally should be used with the GeoIP2 or GeoLite2 City databases.
Example¶
ExampleReader_City demonstrates how to use the City database.
db, err := Open("test-data/test-data/GeoIP2-City-Test.mmdb")if err != nil {log.Panic(err)}defer db.Close()ip, err := netip.ParseAddr("81.2.69.142")if err != nil {log.Panic(err)}record, err := db.City(ip)if err != nil {log.Panic(err)}if !record.HasData() {fmt.Println("No data found for this IP")return}fmt.Printf("City: %v\n", record.City.Names.English)fmt.Printf("Country: %v (%v)\n", record.Country.Names.English, record.Country.ISOCode)fmt.Printf("Time zone: %v\n", record.Location.TimeZone)Output:City: LondonCountry: United Kingdom (GB)Time zone: Europe/London
func (*Reader)Close¶
Close unmaps the database file from virtual memory and returns theresources to the system.
func (*Reader)ConnectionType¶
func (r *Reader) ConnectionType(ipAddressnetip.Addr) (*ConnectionType,error)
ConnectionType takes an IP address as a netip.Addr and returns aConnectionType struct and/or an error.
Example¶
ExampleReader_ConnectionType demonstrates how to use the Connection Type database.
db, err := Open("test-data/test-data/GeoIP2-Connection-Type-Test.mmdb")if err != nil {log.Panic(err)}defer db.Close()ip, err := netip.ParseAddr("1.0.128.0")if err != nil {log.Panic(err)}record, err := db.ConnectionType(ip)if err != nil {log.Panic(err)}if !record.HasData() {fmt.Println("No data found for this IP")return}fmt.Printf("Connection Type: %v\n", record.ConnectionType)Output:Connection Type: Cable/DSL
func (*Reader)Country¶
Country takes an IP address as a netip.Addr and returns a Country structand/or an error. Although this can be used with other databases, thismethod generally should be used with the GeoIP2 or GeoLite2 Countrydatabases.
Example¶
ExampleReader_Country demonstrates how to use the Country database.
db, err := Open("test-data/test-data/GeoIP2-City-Test.mmdb")if err != nil {log.Panic(err)}defer db.Close()ip, err := netip.ParseAddr("81.2.69.142")if err != nil {log.Panic(err)}record, err := db.Country(ip)if err != nil {log.Panic(err)}if !record.HasData() {fmt.Println("No data found for this IP")return}fmt.Printf("Country: %v (%v)\n", record.Country.Names.English, record.Country.ISOCode)fmt.Printf("Continent: %v (%v)\n", record.Continent.Names.English, record.Continent.Code)Output:Country: United Kingdom (GB)Continent: Europe (EU)
func (*Reader)Domain¶
Domain takes an IP address as a netip.Addr and returns aDomain struct and/or an error.
Example¶
ExampleReader_Domain demonstrates how to use the Domain database.
db, err := Open("test-data/test-data/GeoIP2-Domain-Test.mmdb")if err != nil {log.Panic(err)}defer db.Close()ip, err := netip.ParseAddr("1.2.0.0")if err != nil {log.Panic(err)}record, err := db.Domain(ip)if err != nil {log.Panic(err)}if !record.HasData() {fmt.Println("No data found for this IP")return}fmt.Printf("Domain: %v\n", record.Domain)Output:Domain: maxmind.com
func (*Reader)Enterprise¶
func (r *Reader) Enterprise(ipAddressnetip.Addr) (*Enterprise,error)
Enterprise takes an IP address as a netip.Addr and returns an Enterprisestruct and/or an error. This is intended to be used with the GeoIP2Enterprise database.
Example¶
ExampleReader_Enterprise demonstrates how to use the Enterprise database.
db, err := Open("test-data/test-data/GeoIP2-Enterprise-Test.mmdb")if err != nil {log.Panic(err)}defer db.Close()ip, err := netip.ParseAddr("74.209.24.0")if err != nil {log.Panic(err)}record, err := db.Enterprise(ip)if err != nil {log.Panic(err)}if !record.HasData() {fmt.Println("No data found for this IP")return}fmt.Printf("City: %v\n", record.City.Names.English)fmt.Printf("Country: %v (%v)\n", record.Country.Names.English, record.Country.ISOCode)fmt.Printf("ISP: %v\n", record.Traits.ISP)fmt.Printf("Organization: %v\n", record.Traits.Organization)Output:City: ChathamCountry: United States (US)ISP: Fairpoint CommunicationsOrganization: Fairpoint Communications
func (*Reader)ISP¶
ISP takes an IP address as a netip.Addr and returns a ISP struct and/oran error.
Example¶
ExampleReader_ISP demonstrates how to use the ISP database.
db, err := Open("test-data/test-data/GeoIP2-ISP-Test.mmdb")if err != nil {log.Panic(err)}defer db.Close()ip, err := netip.ParseAddr("1.128.0.0")if err != nil {log.Panic(err)}record, err := db.ISP(ip)if err != nil {log.Panic(err)}if !record.HasData() {fmt.Println("No data found for this IP")return}fmt.Printf("ISP: %v\n", record.ISP)fmt.Printf("Organization: %v\n", record.Organization)fmt.Printf("ASN: %v\n", record.AutonomousSystemNumber)Output:ISP: Telstra InternetOrganization: Telstra InternetASN: 1221
typeRepresentedCountry¶
type RepresentedCountry struct {// Names contains localized names for the represented countryNamesNames `json:"names,omitzero" maxminddb:"names"`// ISOCode is the two-character ISO 3166-1 alpha code for the represented// country. Seehttps://en.wikipedia.org/wiki/ISO_3166-1_alpha-2ISOCodestring `json:"iso_code,omitzero" maxminddb:"iso_code"`// Type is a string indicating the type of entity that is representing// the country. Currently this is only "military" but may expand in the future.Typestring `json:"type,omitzero" maxminddb:"type"`// GeoNameID for the represented countryGeoNameIDuint `json:"geoname_id,omitzero" maxminddb:"geoname_id"`// IsInEuropeanUnion is true if the represented country is a member// state of the European UnionIsInEuropeanUnionbool `json:"is_in_european_union,omitzero" maxminddb:"is_in_european_union"`}RepresentedCountry contains data for the represented country associatedwith an IP address. The represented country is the country representedby something like a military base or embassy.
func (RepresentedCountry)HasData¶
func (rRepresentedCountry) HasData()bool
HasData returns true if the RepresentedCountry has any data.
typeUnknownDatabaseTypeError¶
type UnknownDatabaseTypeError struct {DatabaseTypestring}UnknownDatabaseTypeError is returned when an unknown database type isopened.
func (UnknownDatabaseTypeError)Error¶
func (eUnknownDatabaseTypeError) Error()string