exercise-1-7.go (363B)
1 package main 2 3 import ( 4 "fmt" 5 "io" 6 "net/http" 7 "os" 8 ) 9 10 func main() { 11 for _, url := range os.Args[1:] { 12 resp, err := http.Get(url) 13 if err != nil { 14 fmt.Fprintf(os.Stderr, "fetch: %v\n", err) 15 os.Exit(1) 16 } 17 if _, err := io.Copy(os.Stdout, resp.Body); err != nil { 18 resp.Body.Close() 19 fmt.Fprintf(os.Stderr, "io.Copy\n") 20 os.Exit(1) 21 } 22 } 23 } 24 25