/go-http

Go http

Primary LanguageGo

Go HTTP

Net package

resp, err := http.Get("http://google.com")

if err != nil {
    fmt.Println("Error", err)
    os.Exit(1)
}

fmt.Println(resp)

Reponse

//1st way
io.Copy(os.Stdout, resp.Body)
//2nd way
bs := make([]byte, 999999)
len, readErr := resp.Body.Read(bs)

fmt.Println(len)
fmt.Println(string(bs))

if readErr != nil && readErr != io.EOF {
    fmt.Println("Read Error", readErr)
    os.Exit(1)
}