url := "<url>"
resp, err := http.Get(url)
// resp, err := http.Post(url, "text/plain", reqBody) // reqBody []bytes
// resp, err := http.PostForm(url, url.Values{"Foo":{"Bar"}})
// resp, err := http.Post(url, "application/json", reqBody) // reqBody []bytes; reqBody, err := json.Marshal(data)
if err != nil {
return err
}
defer resp.Body.Close()
raw, err := ioutil.ReadAll(resp.Body)
if err != nil {
return err
}
data := struct{
A, B int
}{}
err = json.Unmarshal(raw, &data)
if err != nil {
return err
}