Skip to content

Instantly share code, notes, and snippets.

@kevinquillen
Last active March 11, 2018 18:20
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save kevinquillen/bf2685fd27a57a869094579690484ed0 to your computer and use it in GitHub Desktop.
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