About Go GET request

The simplest GET request

resp, err := http.Get("http://example.com/")

GET request when you want to attach an access token etc.

req, err := http.NewRequest("GET", "http://example.com", nil)
// ...
req.Header.Add("If-None-Match", `W/"wyzzy"`)
resp, err := client.Do(req)
// ...

Close the response body when the request is complete.

defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)

Recommended Posts

About Go GET request
About Go functions
About Go Interface
Learn about Go slices
About Go control syntax
About Go Modules (vgo)
About the basic type of Go
Get a Boolean in Flask's request
What are go mod, go get and go mod vendors?
[Golang] About Go language Producer and Consumer