diff --git a/kit/utils/ip.go b/kit/utils/ip.go index 15c3825..a27a7e2 100644 --- a/kit/utils/ip.go +++ b/kit/utils/ip.go @@ -21,7 +21,15 @@ func GetRealAddressByIP(ip string) string { } dst, _ := ToUTF8("GBK", string(res.Body)) toMap := Json2Map(dst) - return fmt.Sprintf("%s %s", toMap["pro"].(string), toMap["city"].(string)) + pro := "" + city := "" + if tPro, ok := toMap["pro"].(string); ok { + pro = tPro + } + if tCity, ok := toMap["city"].(string); ok { + city = tCity + } + return fmt.Sprintf("%s %s", pro, city) } // 获取局域网ip地址