package main import ( "fmt" "io/ioutil" "net/http" ) func getPage(url string) (int, error) { resp, err := http.Get(url) if err != nil { return 0, err } defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) if err != nil { return 0, err } return len(body), nil } func main() { sites := map[string]string{ "Google": "http://google.com", "Yahoo": "http://yahoo.com", "Bing": "http://bing.com", } for name, url := range sites { length, err := getPage(url) if err != nil { fmt.Printf("%s %s\n", name, err) } fmt.Printf("%s %d\n", name, length) } }