geoip

package
v1.3.7 Latest Latest
Warning

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

Go to latest
Published: May 19, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Lookup

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

Lookup provides country code lookups from MaxMind GeoLite2-Country database.

func New

func New(dbPath string) *Lookup

New creates a Lookup. If the database file doesn't exist, lookups return "".

func (*Lookup) Close

func (l *Lookup) Close()

Close closes the database.

func (*Lookup) Country

func (l *Lookup) Country(ipStr string) string

Country returns the ISO 3166-1 alpha-2 country code for an IP, or "".

func (*Lookup) IsBlocked

func (l *Lookup) IsBlocked(ipStr string) (string, bool)

IsBlocked returns true if the given IP belongs to a blocked country. Returns the country code and blocked status.

func (*Lookup) SetBlocked

func (l *Lookup) SetBlocked(codes []string)

SetBlocked replaces the set of blocked country codes.

Jump to

Keyboard shortcuts

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