Skip to content

Instantly share code, notes, and snippets.

@smtalim
Created May 19, 2014 02:18
Show Gist options
  • Save smtalim/055387c699bc1af42097 to your computer and use it in GitHub Desktop.
Save smtalim/055387c699bc1af42097 to your computer and use it in GitHub Desktop.
Iteration 1 code
package main
import (
"io"
"log"
"net/http"
"os"
)
func main() {
resp, err := http.Get("http://reddit.com/r/golang.json")
if err != nil {
log.Fatal(err)
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
log.Fatal(resp.Status)
}
_, err = io.Copy(os.Stdout, resp.Body)
if err != nil {
log.Fatal(err)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment