Skip to content

Http Client

Advanced · Standard Library & I/O

Making HTTP requests with net/http. (Pairs with testing_advanced/testadv3, which tests an HTTP handler.)

  • http1http.Get, closing the body, reading the response

http1 — HTTP client

Show hint
GET, close the body, read it:
resp, err := http.Get(url); if err != nil { return "", err }
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body); return string(body), err

Source