Zest.

Go: HTTP GET request

A short, tested Go example for http get request. Copy it and adjust the names and paths for your project.

Go
client := &http.Client{Timeout: 10 * time.Second}
resp, err := client.Get("https://api.example.com/items")
if err != nil {
    log.Fatal(err)
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)

Find it in Zest

Search for “go http get request” in Zest and this example appears above the results, with other matches to choose from. Searches stay private.

More Go examples

All Go examples