Unanswered
package main
import (
"log"
"net/http"
"io/ioutil"
)
func main() {
resp, err := http.Get("https://www.google.com")
if err != nil {
log.Fatal(err)
}
defer resp.Body.Close()
if resp.StatusCode == http.StatusOK {
bodyBytes, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Fatal(err)
}
log.Printf(string(bodyBytes))
}
}
541 Views
0
Answers
4 years ago
4 years ago
golang does not work