Loading... - ###0x00.Respones.Body只能读一遍 因为我采用ioutil.ReadAll读取Respones.Body,所以后来发现再次读取Respones.Body发现是空的。这是因为Body会标记读取位置,ReadAll会读取到末尾,因此第二次就会读不到数据。 解决方法: ```go res, _ := ioutil.ReadAll(respones.Body) respones.Body.Close() respones.Body = ioutil.NopCloser(bytes.NewBuffer(res)) ``` Last modification:October 24, 2019 © Allow specification reprint Support Appreciate the author AliPayWeChat Like 0 如果觉得我的文章对你有用,请随意赞赏
One comment
哈哈,我之前也踩过这个坑,用 ReadAll 读完之后才发现 Body 被清空了,调试了半天才明白是读取位置的问题。