From c5b0fe3bb59aeb4043fcccb1666bfa896eb5ee94 Mon Sep 17 00:00:00 2001 From: liyp Date: Sun, 14 Apr 2024 22:08:50 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=AD=97=E7=AC=A6=E4=B8=B2?= =?UTF-8?q?=E5=88=86=E5=89=B2bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/test.go | 2 +- utils/router.go | 2 +- workers/ip.go | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/test/test.go b/test/test.go index 48c9169..236bd51 100644 --- a/test/test.go +++ b/test/test.go @@ -17,7 +17,7 @@ func main() { // 去除末尾的换行符 // raw_msg = strings.TrimRight(raw_msg, "\r\n") - parms := strings.Split(raw_msg, " ") + parms := strings.Fields(raw_msg) worker := workers.NewWorker(parms, "11", "111", "111", "222", raw_msg) fmt.Println("Test:", worker.CheckPermission()) diff --git a/utils/router.go b/utils/router.go index 078b2ff..4c8b4c0 100644 --- a/utils/router.go +++ b/utils/router.go @@ -23,7 +23,7 @@ func Router(data map[string]interface{}) { mid := data["message_id"].(float64) raw_msg := data["raw_message"].(string)[1:] - parms := strings.Split(raw_msg, " ") + parms := strings.Fields(raw_msg) worker := workers.NewWorker(parms, fmt.Sprintf("%d", int(uid)), fmt.Sprintf("%d", int(gid)), role, fmt.Sprintf("%d", int(mid)), raw_msg) diff --git a/workers/ip.go b/workers/ip.go index cd6fe19..dfb2b7a 100644 --- a/workers/ip.go +++ b/workers/ip.go @@ -20,8 +20,8 @@ func (a *Ip) GetMsg() string { // 去除换行符 raw_msg := strings.TrimRight(a.RawMsg, "\n") fmt.Println("raw_msg:", raw_msg) - parms := strings.Split(raw_msg, " ") - url := "https://api.ip.sb/geoip/" + parms[0] + parms := strings.Fields(raw_msg) + url := "https://api.ip.sb/geoip/" + parms[1] // fmt.Println("url: ", url) @@ -50,7 +50,7 @@ func (a *Ip) GetMsg() string { return err.Error() } // 输出响应数据 - // fmt.Println("data: ", data) + fmt.Println("data: ", data) if _, ok := data["code"].(float64); ok { code := data["code"].(float64) if code == 401 {