Last active
March 11, 2018 18:20
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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