Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrNoData = errors.New("No Data") ErrInvalidCountryCode = errors.New("invalid Country Code") )
var ( //go:embed db/GeoLite2-ASN.mmdb GeoLite2ASN []byte //go:embed db/GeoLite2-City.mmdb GeoLite2City []byte //go:embed db/GeoLite2-Country.mmdb GeoLite2Country []byte )
Functions ¶
func VaidateCountryCode ¶
ValidateCountryCode returns whether string v is a valid two-character ISO 3166-1 country code.
Types ¶
type ASN ¶
type ASN struct { Organization string `maxminddb:"autonomous_system_organization"` Number uint `maxminddb:"autonomous_system_number"` }
func (*ASN) UnmarshalMaxMindDB ¶
UnmarshalMaxMindDB implements the github.com/oschwald/maxminddb-golang/v2/mmdbdata.Unmarshaler interface
type Country ¶
type Country struct { Name string // Full name of the country (eg.: "Hungary") Code string // Two-character ISO 3166-1 country code (eg.: "HU") }
func (*Country) UnmarshalMaxMindDB ¶
UnmarshalMaxMindDB implements the github.com/oschwald/maxminddb-golang/v2/mmdbdata.Unmarshaler interface
type GeoIP ¶
type GeoIP struct {
// contains filtered or unexported fields
}
func NewGeoIPFromBytes ¶
NewGeoIPFromBytes parses mmdb bytes b and returns a pointer to GeoIP.
func NewGeoIPFromFile ¶
NewGeoIPFromFile parses an mmdb file in path and returns a pointer to GeoIP.
func (*GeoIP) ASN ¶
ASN returns the ASN associated with the IP address addr.
If no data found for the given address, returns ErrNoData.
func (*GeoIP) Country ¶
Country returns the country associated with IP address addr.
If no data found for the given address, returns ErrNoData.
func (*GeoIP) IsASN ¶
IsASN returns whether IP address addr belong to ASN Number n.
If no data found for the given address, returns ErrNoData.