package main import ( "fmt" "io/ioutil" "net/http" ) func loadWebPage(webURL string) ([]byte, error) { resp, err := http.Get(webURL) //reads html as a slice of bytes html, err := ioutil.ReadAll(resp.Body) defer resp.Body.Close() //check response codes if resp.StatusCode >= 400 && resp.StatusCode <= 499 { err = fmt.Errorf("got response code %v", resp.StatusCode) } return html, err }