aboutsummaryrefslogtreecommitdiff
path: root/libgo/go/net/http/example_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/net/http/example_test.go')
-rw-r--r--libgo/go/net/http/example_test.go7
1 files changed, 5 insertions, 2 deletions
diff --git a/libgo/go/net/http/example_test.go b/libgo/go/net/http/example_test.go
index c677d52..2f411d1 100644
--- a/libgo/go/net/http/example_test.go
+++ b/libgo/go/net/http/example_test.go
@@ -45,12 +45,15 @@ func ExampleGet() {
if err != nil {
log.Fatal(err)
}
- robots, err := io.ReadAll(res.Body)
+ body, err := io.ReadAll(res.Body)
res.Body.Close()
+ if res.StatusCode > 299 {
+ log.Fatalf("Response failed with status code: %d and\nbody: %s\n", res.StatusCode, body)
+ }
if err != nil {
log.Fatal(err)
}
- fmt.Printf("%s", robots)
+ fmt.Printf("%s", body)
}
func ExampleFileServer() {