From a9908988c5d11c2cb897acf7799924709f49bd34 Mon Sep 17 00:00:00 2001 From: luhaoling <2198702716@qq.com> Date: Fri, 19 Jan 2024 09:52:42 +0800 Subject: [PATCH] fix: fix the valiable unused error --- internal/api/msg.go | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/internal/api/msg.go b/internal/api/msg.go index 56154a531..cac357df3 100644 --- a/internal/api/msg.go +++ b/internal/api/msg.go @@ -419,7 +419,6 @@ func (m *MessageApi) CallbackExample(c *gin.Context) { mapStruct := make(map[string]any) // Processing text messages if req.ContentType == constant.Picture || req.ContentType == constant.Text { - var err error user, err := m.userRpcClient.GetUserInfo(c, robotics) if err != nil { log.ZError(c, "CallbackExample get Sender failed", err) @@ -438,9 +437,6 @@ func (m *MessageApi) CallbackExample(c *gin.Context) { log.ZDebug(c, "callback", "text", text) mapStruct["content"] = text.Content } else { - mapStructSnap := make(map[string]interface{}) - mapStructBig := make(map[string]interface{}) - mapStructSource := make(map[string]interface{}) err = json.Unmarshal([]byte(req.Content), &picture) if err != nil { log.ZError(c, "CallbackExample unmarshal failed", err) @@ -462,24 +458,24 @@ func (m *MessageApi) CallbackExample(c *gin.Context) { picture.SnapshotPicture.Type = picture.SourcePicture.Type } - mapStructSnap, err = convertStructToMap(picture.SnapshotPicture) - if err != nil { + mapStructSnap := make(map[string]interface{}) + if mapStructSnap, err = convertStructToMap(picture.SnapshotPicture); err != nil { log.ZError(c, "CallbackExample struct to map failed", err) apiresp.GinError(c, err) return } mapStruct["snapshotPicture"] = mapStructSnap - mapStructBig, err = convertStructToMap(picture.BigPicture) - if err != nil { + mapStructBig := make(map[string]interface{}) + if mapStructBig, err = convertStructToMap(picture.BigPicture); err != nil { log.ZError(c, "CallbackExample struct to map failed", err) apiresp.GinError(c, err) return } mapStruct["bigPicture"] = mapStructBig - mapStructSource, err = convertStructToMap(picture.SourcePicture) - if err != nil { + mapStructSource := make(map[string]interface{}) + if mapStructSource, err = convertStructToMap(picture.SourcePicture); err != nil { log.ZError(c, "CallbackExample struct to map failed", err) apiresp.GinError(c, err) return