MCPcopy Create free account
hub / github.com/MengMengCode/GetRealityDomain / GetGeo

Method GetGeo

types.go:61–75  ·  view source on GitHub ↗

GetGeo 获取IP的地理位置代码

(ip net.IP)

Source from the content-addressed store, hash-verified

59
60// GetGeo 获取IP的地理位置代码
61func (g *Geo) GetGeo(ip net.IP) string {
62 if g.geoReader == nil {
63 return "UNKNOWN"
64 }
65
66 g.mu.Lock()
67 defer g.mu.Unlock()
68
69 country, err := g.geoReader.Country(ip)
70 if err != nil {
71 return "UNKNOWN"
72 }
73
74 return country.Country.IsoCode
75}
76
77// Close 关闭地理位置数据库
78func (g *Geo) Close() error {

Callers 1

scanSingleIPFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected