location

package
v0.0.0-...-c5d5a31 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2020 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package location fetches geolocation data

Index

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   `maxminddb:"geoname_id" json:"geoname_id" xml:"geoname_id"`
		Names     xmlMap `maxminddb:"names" json:"names" xml:"names"`
	} `maxminddb:"city" json:"city" xml:"city"`
	Continent struct {
		Code      string `maxminddb:"code" json:"code" xml:"code"`
		GeoNameID uint   `maxminddb:"geoname_id" json:"geoname_id" xml:"geoname_id"`
		Names     xmlMap `maxminddb:"names" json:"names" xml:"names"`
	} `maxminddb:"continent" json:"continent" xml:"continent"`
	Country struct {
		GeoNameID         uint   `maxminddb:"geoname_id" json:"geoname_id" xml:"geoname_id"`
		IsInEuropeanUnion bool   `maxminddb:"is_in_european_union" json:"is_eu" xml:"is_eu"`
		IsoCode           string `maxminddb:"iso_code" json:"iso_code" xml:"iso_code"`
		Names             xmlMap `maxminddb:"names" json:"names" xml:"names"`
	} `maxminddb:"country" json:"country" xml:"country"`
	Location struct {
		AccuracyRadius uint16  `maxminddb:"accuracy_radius" json:"accuracy_radius" xml:"accuracy_radius"`
		Latitude       float64 `maxminddb:"latitude" json:"latitude" xml:"latitude"`
		Longitude      float64 `maxminddb:"longitude" json:"longitude" xml:"longitude"`
		MetroCode      uint    `maxminddb:"metro_code" json:"metro_code" xml:"metro_code"`
		TimeZone       string  `maxminddb:"time_zone" json:"time_zone" xml:"time_zone"`
	} `maxminddb:"location" json:"location" xml:"location"`
	Postal struct {
		Code string `maxminddb:"code" json:"code" xml:"code"`
	} `maxminddb:"postal" json:"postal" xml:"postal"`
	RegisteredCountry struct {
		GeoNameID         uint   `maxminddb:"geoname_id" json:"geoname_id"  xml:"geoname_id"`
		IsInEuropeanUnion bool   `maxminddb:"is_in_european_union" json:"is_eu" xml:"is_eu"`
		IsoCode           string `maxminddb:"iso_code" json:"iso_code" xml:"iso_code"`
		Names             xmlMap `maxminddb:"names" json:"names" xml:"names"`
	} `maxminddb:"registered_country" json:"registered_country" xml:"registered_country"`
	RepresentedCountry struct {
		GeoNameID         uint   `maxminddb:"geoname_id" json:"geoname_id"  xml:"geoname_id"`
		IsInEuropeanUnion bool   `maxminddb:"is_in_european_union" json:"is_eu" xml:"is_eu"`
		IsoCode           string `maxminddb:"iso_code" json:"iso_code" xml:"iso_code"`
		Names             xmlMap `maxminddb:"names" json:"names" xml:"names"`
		Type              string `maxminddb:"type"  json:"type" xml:"type"`
	} `maxminddb:"represented_country"  json:"represented_country" xml:"represented_country"`
	Subdivisions []Subdivision `maxminddb:"subdivisions" json:"subdivisions" xml:"subdivisions"`
	Traits       struct {
		IsAnonymousProxy    bool `maxminddb:"is_anonymous_proxy" json:"is_anonymous_proxy" xml:"is_anonymous_proxy"`
		IsSatelliteProvider bool `maxminddb:"is_satellite_provider" json:"is_satellite_provider" xml:"is_satellite_provider"`
	} `maxminddb:"traits" json:"traits" xml:"traits"`
}

City is like geoip2.City but adds json tags

type Fetcher

type Fetcher interface {
	Fetch(ip net.IP) (*City, error)
}

Fetcher retrieves stock quotes

type JiveData

type JiveData struct {
	HTTPClient *http.Client
	Key        string
}

JiveData is a location data provider

func (*JiveData) Fetch

func (j *JiveData) Fetch(ip net.IP) (*City, error)

Fetch gets geolocation data from an IP Address

type Location

type Location struct {
	Latitude  float64
	Longitude float64
}

Location is the lat/long of a place

type MaxMind

type MaxMind struct {
	DB string // location of MaxMind database
}

MaxMind is a location data provider For install instructions: https://dev.maxmind.com/geoip/geoipupdate/

func (*MaxMind) Fetch

func (m *MaxMind) Fetch(ip net.IP) (*City, error)

Fetch gets geolocation data from an IP Address

type Subdivision

type Subdivision struct {
	GeoNameID uint   `maxminddb:"geoname_id" json:"geoname_id" xml:"geoname_id"`
	IsoCode   string `maxminddb:"iso_code" json:"iso_code" xml:"iso_code"`
	Names     xmlMap `maxminddb:"names" json:"names" xml:"names"`
}

Subdivision adds json tags to maxmind

Jump to

Keyboard shortcuts

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