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