Skip to content

Instantly share code, notes, and snippets.

@aln787
Created January 17, 2015 15:31
Show Gist options
  • Save aln787/62d21ddc1a709cb91241 to your computer and use it in GitHub Desktop.
Save aln787/62d21ddc1a709cb91241 to your computer and use it in GitHub Desktop.
Go Lang HTTP Get Example
package main
import (
"fmt"
"io/ioutil"
"net/http"
)
func checkErr(e error) {
if e != nil {
panic(e)
}
}
func main() {
res, err := http.Get("http://golang.org/pkg/net/http/")
checkErr(err)
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
checkErr(err)
fmt.Println(string(body))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment