From 9d01e83d7102f9257c61c1e32e1e113df37e2092 Mon Sep 17 00:00:00 2001 From: junleea <354425203@qq.com> Date: Sun, 15 Dec 2024 18:02:10 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=94=A8=E6=88=B7=E5=90=8C?= =?UTF-8?q?=E6=AD=A5=E8=AF=B7=E6=B1=82=E6=95=B0=E6=8D=AE=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- worker/req.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/worker/req.go b/worker/req.go index 4f40dfe..28ac772 100644 --- a/worker/req.go +++ b/worker/req.go @@ -7,6 +7,7 @@ import ( "io" "io/ioutil" "net/http" + "strconv" "strings" "videoplayer/proto" ) @@ -159,15 +160,16 @@ func SyncDataFromMasterReq2(url string, data proto.SyncUserReq) (proto.UserSync, } defer resp.Body.Close() //解析数据 - var m map[string]interface{} + var m map[string]string err = json.NewDecoder(resp.Body).Decode(&m) if err != nil { return res, err } - if m["code"].(float64) != 0 { + code, _ := strconv.Atoi(m["code"]) + if code != 0 { return res, err } - err = json.Unmarshal([]byte(m["data"].(string)), &res) + err = json.Unmarshal([]byte(m["data"]), &res) if err != nil { fmt.Println("SyncDataFromMasterReq2 error decode data:", err) return res, err