geolocate

package
v0.0.0-...-73376d2 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2023 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Overview

Package geolocate looks up ISO country codes and names

Package geolocate performs IP geolocation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Initialize

func Initialize(databasePath string) error

Initialize starts the geolocation service with the MaxMind MMDB file

func IsCountryCode

func IsCountryCode(code string) bool

IsCountryCode returns whether the code is a valid country code

Types

type Country

type Country struct {
	Code string
	Name string
}

Country provides country code and country names

type IPGeolocation

type IPGeolocation struct {
	CountryName string `json:"country_name,omitempty"`
	// ISO 3166 2-letter uppercase contry code
	CountryCode string `json:"country_code,omitempty"`
}

IPGeolocation stores the country information for an IP

func Geolocate

func Geolocate(ip string) (*IPGeolocation, error)

Geolocate uses maxmind to geolocate IP to country

Jump to

Keyboard shortcuts

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