Skip to content

Instantly share code, notes, and snippets.

@kevinquillen
Last active March 11, 2018 18:20
Embed
What would you like to do?
Just learning a little bit about Go.. using http client to get a response and look at the data.
package main
import "fmt"
import "net/http"
import "io/ioutil"
import "time"
import "log"
func main() {
var url = "[redacted]/api/v1/room"
var netClient = &http.Client{
Timeout: time.Second * 10,
}
response, err := netClient.Get(url)
if err != nil {
log.Fatalf("error %s", err)
}
defer response.Body.Close()
content, err := ioutil.ReadAll(response.Body)
if err != nil {
log.Fatalf("error %s", err)
}
fmt.Printf("%s", content)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment