Exemple #1
0
func main() {
	if len(os.Args) != 2 {
		log.Fatalf("usage: %v $URL", os.Args[0])
	}
	if _, err := http.Get(os.Stdout, os.Args[1]); err != nil {
		log.Fatalf("unable to fetch %q: %v", os.Args[1], err)
	}
}
Exemple #2
0
func main() {

	fmt.Println("Getching google page")
	if _, err := http.Get(os.Stdout, "http://www.google.pl/"); err != nil {
		fmt.Printf("could not fetch: %v", err)
	}

	// Lets read it to memory! ha biatches
	fmt.Printf("\n\nNow to buffer\n\n")

	var buf *bytes.Buffer = new(bytes.Buffer)
	if _, err := http.Get(buf, "http://www.google.pl"); err != nil {
		fmt.Printf("could not fetch: %v", err)
	} else {
		fmt.Printf("%s", buf.String())
	}

}