79728851

Date: 2025-08-07 16:15:29
Score: 0.5
Natty:
Report link

Using var body []byte like this creates slice with a capacity 0. Passing this into Read() means that it will try to fill the capacity-0 slice with bytes. Since the slice has no more capacity, it returns with no error, and with the "empty" slice.

Replacing it with body, err := io.ReadAll(resp.Body) works, since io.ReadAll() consumes the entire Reader and returns it as a []byte.

Reasons:
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: bigyihsuan