geoip

package
v0.0.0-...-9337120 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GeoipMmdbByte []byte

Functions

This section is empty.

Types

type Geoip2

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

Geoip2 地理位置解析结构体

func NewGeoip

func NewGeoip(geoipMmdbByte []byte) (geoip *Geoip2, err error)

打开文件获取mmdb句柄

func (*Geoip2) Close

func (this *Geoip2) Close() (err error)

func (*Geoip2) Get

func (this *Geoip2) Get() *Res

func (*Geoip2) GetAreaFromIP

func (this *Geoip2) GetAreaFromIP(rawIP string) (province, city string, err error)

通过ip获取地区

type Res

type Res struct {
	City struct {
		Names struct {
			ZhCN string `maxminddb:"zh-CN"`
		} `maxminddb:"names"`
	} `maxminddb:"city"`
	Country struct {
		Names struct {
			ZhCN string `maxminddb:"zh-CN"`
		} `maxminddb:"names"`
	} `maxminddb:"country"`
	Subdivisions []struct {
		Names struct {
			ZhCN string `maxminddb:"zh-CN"`
		} `maxminddb:"names"`
	} `maxminddb:"subdivisions"`
}

Jump to

Keyboard shortcuts

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