xml.NewDecoder(resp.Body).Decode Giving EOF Error _GOLang

后端 未结 1 1782
南笙
南笙 2021-01-15 06:12

I\'m trying to Decode XML from body a html response.

=>I saved this response body as string to a Variable and successfully decoded Using xml.Unmarshal Functio

相关标签:
1条回答
  • 2021-01-15 06:49

    If you already read the Body io.ReadCloser once (with conts1, err := ioutil.ReadAll(resp1.Body)), you cannot ask another function to read it again (or you will get the EOF error message).

    I saved this response body as string to a Variable and successfully decoded Using xml.Unmarshal Function.

    That seems the easiest approach to use the body content multiple times.

    0 讨论(0)
提交回复
热议问题