geoip

package
v0.0.0-...-b118cd4 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Location

type Location struct {
	CountryCode string `json:"countryCode"`

	Latitude  float64 `json:"latitude"`
	Longitude float64 `json:"longitude"`
}

A Location represents an ISO 3166-1 A-2 country codes and an approximate latitude/longitude.

type Locator

type Locator interface {
	// Close closes the Locator.
	Close() error
	// Locate maps IP addresses to a Location.
	Locate(ip *net.IPAddr) (Location, error)
}

A Locator maps IP addresses to their location. It is assumed that it implementations are thread-safe.

func NewMaxMindLocator

func NewMaxMindLocator(path string) (Locator, error)

NewMaxMindLocator returns a Locator that uses an underlying MaxMind database. If no path is provided, a default embedded GeoLite2-City database is used.

Jump to

Keyboard shortcuts

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