liuxiaolong
2021-01-20 2b337fa6e928c209aafe616dcdde351595c63c1e
使用reply解析doReq返回的结果
1个文件已修改
14 ■■■■ 已修改文件
sbusClient.go 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
sbusClient.go
@@ -36,6 +36,12 @@
    Body                    []byte                  `json:"body"`
}
type reply struct {
    Success             bool                         `json:"success"`
    Msg                 string                         `json:"msg"`
    Data                 interface{}                 `json:"data"`
}
func (sc SBusClient) DoGetRequest(url string, params map[string]string, headers map[string]string) ([]byte, error) {
    if sc.nodes == nil || len(sc.nodes) == 0 {
        return nil, errors.New("invalid netNodes")
@@ -165,13 +171,7 @@
        return nil, fmt.Errorf("doReq s.SendandrecvTimeout result n:%d", n)
    } else {
        if len(ret) > 0 {
            var retMsg MsgInfo
            err = json.Unmarshal(ret[0].Data, &retMsg)
            if err != nil {
                logPrint("doReq unmarshal to MsgInfo err:", err)
                return nil, err
            }
            return retMsg.Body, nil
            return ret[0].Data, nil
        }
        return nil, fmt.Errorf("no any response")
    }