From 0b5322dd2de9bc58a0ad876f24aff4ba18f77d32 Mon Sep 17 00:00:00 2001 From: PandaX-Go Date: Sat, 10 Aug 2024 11:24:30 +0800 Subject: [PATCH] =?UTF-8?q?[fix]=20=E7=94=9F=E6=88=90IP=EF=BC=8C=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E5=8F=AF=E8=83=BD=E4=B8=8D=E6=98=AF=E5=AD=97=E7=AC=A6?= =?UTF-8?q?=E4=B8=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kit/utils/ip.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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地址