A standard http req like:
data, _ := json.Marshal(map[string]any{
"passwd": "123",
"name": "xx",
})
req, err := http.Post("http://localhost:8085/login", "application/json", bytes.NewReader(data))
if err != nil {
panic(err)
}
defer req.Body.Close()
io.Copy(io.Discard, req.Body) // must ?
I need do many http requests.If i don’t care respone ,should i use io.Copy(io.Discard, req.Body)
?
I see some articles says resp.Body.Close()
will reads and discards the remaining response body data.