geoip

package
v0.0.0-...-924ede1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 8, 2019 License: MIT Imports: 3 Imported by: 3

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type City

type City struct {
	City struct {
		GeoNameID uint              `json:"geoname_id,omitempty"`
		Names     map[string]string `json:"names,omitempty"`
	} `json:"city,omitempty"`
	Continent struct {
		Code      string            `json:"code,omitempty"`
		GeoNameID uint              `json:"geoname_id,omitempty"`
		Names     map[string]string `json:"names,omitempty"`
	} `json:"continent,omitempty"`
	Country struct {
		GeoNameID         uint              `json:"geoname_id,omitempty"`
		IsInEuropeanUnion bool              `json:"is_in_european_union,omitempty"`
		IsoCode           string            `json:"iso_code,omitempty"`
		Names             map[string]string `json:"names,omitempty"`
	} `json:"country,omitempty"`
	Location struct {
		AccuracyRadius uint16  `json:"accuracy_radius,omitempty"`
		Latitude       float64 `json:"latitude,omitempty"`
		Longitude      float64 `json:"longitude,omitempty"`
		MetroCode      uint    `json:"metro_code,omitempty"`
		TimeZone       string  `json:"time_zone,omitempty"`
	} `json:"location,omitempty"`
	Postal struct {
		Code string `json:"code,omitempty"`
	} `json:"postal,omitempty"`
	RegisteredCountry struct {
		GeoNameID         uint              `json:"geoname_id,omitempty"`
		IsInEuropeanUnion bool              `json:"is_in_european_union,omitempty"`
		IsoCode           string            `json:"iso_code,omitempty"`
		Names             map[string]string `json:"names,omitempty"`
	} `json:"registered_country,omitempty"`
	RepresentedCountry struct {
		GeoNameID         uint              `json:"geoname_id,omitempty"`
		IsInEuropeanUnion bool              `json:"is_in_european_union,omitempty"`
		IsoCode           string            `json:"iso_code,omitempty"`
		Names             map[string]string `json:"names,omitempty"`
		Type              string            `json:"type,omitempty"`
	} `json:"represented_country,omitempty"`
	Subdivisions []struct {
		GeoNameID uint              `json:"geoname_id,omitempty"`
		IsoCode   string            `json:"iso_code,omitempty"`
		Names     map[string]string `json:"names,omitempty"`
	} `json:"subdivisions,omitempty"`
	Traits struct {
		IsAnonymousProxy    bool `json:"is_anonymous_proxy,omitempty"`
		IsSatelliteProvider bool `json:"is_satellite_provider,omitempty"`
	} `json:"traits,omitempty"`
}

The City struct corresponds to the data in the GeoIP2/GeoLite2 City databases.

type Country

type Country struct {
	Continent struct {
		Code      string            `json:"code,omitempty"`
		GeoNameID uint              `json:"geoname_id,omitempty"`
		Names     map[string]string `json:"names,omitempty"`
	} `json:"continent,omitempty"`
	Country struct {
		GeoNameID         uint              `json:"geoname_id,omitempty"`
		IsInEuropeanUnion bool              `json:"is_in_european_union,omitempty"`
		IsoCode           string            `json:"iso_code,omitempty"`
		Names             map[string]string `json:"names,omitempty"`
	} `json:"country,omitempty"`
	RegisteredCountry struct {
		GeoNameID         uint              `json:"geoname_id,omitempty"`
		IsInEuropeanUnion bool              `json:"is_in_european_union,omitempty"`
		IsoCode           string            `json:"iso_code,omitempty"`
		Names             map[string]string `json:"names,omitempty"`
	} `json:"registered_country,omitempty"`
	RepresentedCountry struct {
		GeoNameID         uint              `json:"geoname_id,omitempty"`
		IsInEuropeanUnion bool              `json:"is_in_european_union,omitempty"`
		IsoCode           string            `json:"iso_code,omitempty"`
		Names             map[string]string `json:"names,omitempty"`
		Type              string            `json:"type,omitempty"`
	} `json:"represented_country,omitempty"`
	Traits struct {
		IsAnonymousProxy    bool `json:"is_anonymous_proxy,omitempty"`
		IsSatelliteProvider bool `json:"is_satellite_provider,omitempty"`
	} `json:"traits,omitempty"`
}

The Country struct corresponds to the data in the GeoIP2/GeoLite2 Country databases.

func GeoIP

func GeoIP(ipaddr string) (country *Country, err error)

GeoIP ...

Example

ExampleGeoIP ...

record, _ := GeoIP("216.15.114.53")
fmt.Println(record.Country.Names["en"])
Output:

United States

func NewCountry

func NewCountry(g *geoip2.Country) (c *Country)

NewCountry ...

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL