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 {