From 5def1cd66816911df699b7f41c09dd9a0ba4d62a Mon Sep 17 00:00:00 2001 From: liyp Date: Thu, 18 Apr 2024 17:54:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96ip=E6=8F=92=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- workers/ip.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/workers/ip.go b/workers/ip.go index bd272e6..1519719 100644 --- a/workers/ip.go +++ b/workers/ip.go @@ -52,12 +52,16 @@ func (a *Ip) GetMsg() string { } else { defer resp.Body.Close() body, err := io.ReadAll(resp.Body) - // println(string(body)) + println(string(body)) if err != nil { fmt.Println("err:", err) + } else { var resp_data map[string]interface{} - json.Unmarshal(body, &resp_data) + err := json.Unmarshal(body, &resp_data) + if err != nil { + return "DNS解析失败!" + } ip = resp_data["data"].(map[string]interface{})["ip"].(string) // print("ip: ", ip) }