feat(适配特性): 适配纯真IP库社区版更新(2024-06-19)地理位置格式

This commit is contained in:
2024-06-20 00:38:19 +08:00
parent 26b587798e
commit 25daf60573
5 changed files with 98 additions and 45 deletions

View File

@@ -11,10 +11,22 @@ func init() {
}
func TestQueryIP(t *testing.T) {
queryIp := "1.1.1.1"
city, isp, err := QueryIP(queryIp)
queryIp := "119.29.29.29"
location, err := QueryIP(queryIp)
if err != nil {
t.Fatal(err)
}
t.Logf("城市:%s运营商%s", city, isp)
emptyVal := func(val string) string {
if val != "" {
return val
}
return "未知"
}
t.Logf("国家:%s省份%s城市%s区县%s运营商%s",
emptyVal(location.Country),
emptyVal(location.Province),
emptyVal(location.City),
emptyVal(location.District),
emptyVal(location.ISP),
)
}