geodb

package
v6.8.3 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GeoDB

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

GeoDB maps IPs to their geological location based on MaxMinds GeoLite2 or GeoIP2 database.

func NewGeoDB

func NewGeoDB(licenseKey, downloadPath string) (*GeoDB, error)

NewGeoDB creates a new GeoDB for given license key.

func (*GeoDB) GetLocation

func (db *GeoDB) GetLocation(ip string) (string, string)

GetLocation looks up the country code, subdivision (region), and city for given IP. If the IP is invalid it will return an empty string. The country code is returned in lowercase.

func (*GeoDB) Update

func (db *GeoDB) Update() error

Update downloads and unpacks the MaxMind GeoLite2 database.

func (*GeoDB) UpdateFromFile

func (db *GeoDB) UpdateFromFile(path string) error

UpdateFromFile updates GeoDB from given file instead of downloading the database.

Jump to

Keyboard shortcuts

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