mirror of
https://github.com/xiaoqidun/qqwry.git
synced 2025-12-09 01:12:55 +08:00
feat(适配特性): 适配纯真IP库社区版更新(2024-06-19)地理位置格式
This commit is contained in:
@@ -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),
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user