Skip to content

Instantly share code, notes, and snippets.

@xcv58
Created February 12, 2016 17:40
Show Gist options
  • Select an option

  • Save xcv58/23586dbb6f5fd989fa14 to your computer and use it in GitHub Desktop.

Select an option

Save xcv58/23586dbb6f5fd989fa14 to your computer and use it in GitHub Desktop.
Go http get example
package main
import (
"fmt"
"io/ioutil"
"net/http"
)
func main() {
resp, err := http.Get("https://www.ops-class.org/")
if err != nil {
fmt.Println(err);
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
fmt.Println(err);
}
fmt.Println(string(body))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment