]> Cypherpunks.ru repositories - gostls13.git/commitdiff
io: add error check to TeeReader Example
authorjiahua wang <wjh180909@gmail.com>
Sat, 2 Oct 2021 14:50:31 +0000 (22:50 +0800)
committerIan Lance Taylor <iant@golang.org>
Thu, 11 Nov 2021 19:34:23 +0000 (19:34 +0000)
Change-Id: I0b94bdced47483c6412e9979ce2d103fbfc52afb
Reviewed-on: https://go-review.googlesource.com/c/go/+/353729
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Carlos Amedee <carlos@golang.org>

src/io/example_test.go

index f6d9fd575f9be8d822f03e46cb18cd36466ce53d..419e449982ad5cabc16b92aa628b22897b9f5848 100644 (file)
@@ -142,7 +142,9 @@ func ExampleTeeReader() {
        r = io.TeeReader(r, os.Stdout)
 
        // Everything read from r will be copied to stdout.
-       io.ReadAll(r)
+       if _, err := io.ReadAll(r); err != nil {
+               log.Fatal(err)
+       }
 
        // Output:
        // some io.Reader stream to be read