]> Cypherpunks repositories - gostls13.git/commitdiff
crypto/rand: simplify example to exploit properties of ReadFull
authorRob Pike <r@golang.org>
Mon, 12 Aug 2013 02:52:23 +0000 (12:52 +1000)
committerRob Pike <r@golang.org>
Mon, 12 Aug 2013 02:52:23 +0000 (12:52 +1000)
No need for the complex condition.
Fixes #6089

R=golang-dev, mischief, adg
CC=golang-dev
https://golang.org/cl/12731043

src/pkg/crypto/rand/example_test.go

index 5af8e46f5d4511042758c5557028b5dc4951ffce..5db9e92cb7f6522572096209caf3b68040fdfaac 100644 (file)
@@ -16,8 +16,8 @@ import (
 func ExampleRead() {
        c := 10
        b := make([]byte, c)
-       n, err := io.ReadFull(rand.Reader, b)
-       if n != len(b) || err != nil {
+       _, err := io.ReadFull(rand.Reader, b)
+       if err != nil {
                fmt.Println("error:", err)
                return
        }