kayon / iploc

每秒百万高性能IP查询库,使用纯真IP库,国内省、市、县,qqwry.dat转换工具:GBK转为UTF-8
BSD 3-Clause "New" or "Revised" License
99 stars 38 forks source link

国家获取错误 #4

Closed chriskaliX closed 3 years ago

chriskaliX commented 3 years ago

一些数据会默认不带国家(可能是纯真库的问题),导致后面的省和市直接作为国家。 Example: ip := "211.93.60.102" fmt.Println(myloc.IPLoc.Find(ip).Country) 输出结果为:黑龙江省哈尔滨市道外区

chriskaliX commented 3 years ago

好像只有国内会这样,做个前置判断不知道行不行,写了个简单的demo

func prefix(country string) string { for index, value := range []rune(country) { if string(value) == "市" { return string([]rune(country)[:index+1]) } if string(value) == "省" { return string([]rune(country)[:index+1]) } } return "" }