geolocation

package
v0.30.1 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2024 License: BSD-3-Clause Imports: 28 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type City

type City struct {
	GeoNameID int `gorm:"column:geoname_id"`
	CityName  string
}

type Country

type Country struct {
	CountryISOCode string `gorm:"column:country_iso_code"`
	CountryName    string
}

type GeoNames added in v0.26.1

type GeoNames struct {
	GeoNameID           int    `gorm:"column:geoname_id"`
	LocaleCode          string `gorm:"column:locale_code"`
	ContinentCode       string `gorm:"column:continent_code"`
	ContinentName       string `gorm:"column:continent_name"`
	CountryIsoCode      string `gorm:"column:country_iso_code"`
	CountryName         string `gorm:"column:country_name"`
	Subdivision1IsoCode string `gorm:"column:subdivision_1_iso_code"`
	Subdivision1Name    string `gorm:"column:subdivision_1_name"`
	Subdivision2IsoCode string `gorm:"column:subdivision_2_iso_code"`
	Subdivision2Name    string `gorm:"column:subdivision_2_name"`
	CityName            string `gorm:"column:city_name"`
	MetroCode           string `gorm:"column:metro_code"`
	TimeZone            string `gorm:"column:time_zone"`
	IsInEuropeanUnion   string `gorm:"column:is_in_european_union"`
}

func (*GeoNames) TableName added in v0.26.1

func (*GeoNames) TableName() string

type Geolocation

type Geolocation struct {
	// contains filtered or unexported fields
}

func NewGeolocation

func NewGeolocation(ctx context.Context, dataDir string, autoUpdate bool) (*Geolocation, error)

func (*Geolocation) GetAllCountries

func (gl *Geolocation) GetAllCountries() ([]Country, error)

GetAllCountries retrieves a list of all countries.

func (*Geolocation) GetCitiesByCountry

func (gl *Geolocation) GetCitiesByCountry(countryISOCode string) ([]City, error)

GetCitiesByCountry retrieves a list of cities in a specific country based on the country's ISO code.

func (*Geolocation) Lookup

func (gl *Geolocation) Lookup(ip net.IP) (*Record, error)

func (*Geolocation) Stop

func (gl *Geolocation) Stop() error

type Record

type Record struct {
	City struct {
		GeonameID uint `maxminddb:"geoname_id"`
		Names     struct {
			En string `maxminddb:"en"`
		} `maxminddb:"names"`
	} `maxminddb:"city"`
	Continent struct {
		GeonameID uint   `maxminddb:"geoname_id"`
		Code      string `maxminddb:"code"`
	} `maxminddb:"continent"`
	Country struct {
		GeonameID uint   `maxminddb:"geoname_id"`
		ISOCode   string `maxminddb:"iso_code"`
	} `maxminddb:"country"`
}

type SqliteStore

type SqliteStore struct {
	// contains filtered or unexported fields
}

SqliteStore represents a location storage backed by a Sqlite DB.

func NewSqliteStore

func NewSqliteStore(ctx context.Context, dataDir string, dbPath string) (*SqliteStore, error)

func (*SqliteStore) GetAllCountries

func (s *SqliteStore) GetAllCountries() ([]Country, error)

GetAllCountries returns a list of all countries in the store.

func (*SqliteStore) GetCitiesByCountry

func (s *SqliteStore) GetCitiesByCountry(countryISOCode string) ([]City, error)

GetCitiesByCountry retrieves a list of cities from the store based on the given country ISO code.

Jump to

Keyboard shortcuts

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