geoip

package
v1.4.2 Latest Latest
Warning

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

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

Documentation

Overview

Copyright (c) Tobias Schäfer. All rights reserved. Licensed under the MIT License, see LICENSE file in the project root for details.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GeoIP

type GeoIP struct {
	Reader   *geoip2.Reader
	Database string
}

GeoIP is a wrapper around the GeoIP2 City database reader.

func NewGeoIP added in v1.0.0

func NewGeoIP(database string) (*GeoIP, error)

NewGeoIP creates a new GeoIP instance by loading the specified GeoIP2 City database file.

func (*GeoIP) Close added in v1.0.0

func (g *GeoIP) Close() error

Close closes the GeoIP database reader.

func (*GeoIP) Location added in v1.0.0

func (g *GeoIP) Location(ip netip.Addr) *Location

Location retrieves the geographical location information for the given IP address. If no location data is found, it returns nil.

type Location

type Location struct {
	Country string
	City    string
	Lat     float64
	Lon     float64
}

Location represents geographical location information.

Jump to

Keyboard shortcuts

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