You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Go version 1.3 (and 1.2)
The documentation states that crypto/rand.Read() returns a byte count equal to the
length of the incoming slice whenever err==nil. This is contradicted with our code and
is reproducible on the playground:
http://play.golang.org/p/xd3W7l4Q-l
Source:
package main
import (
"crypto/rand"
"fmt"
)
func foo(i int) error {
buf := make([]byte, 20)
n, err := rand.Reader.Read(buf)
switch {
case err != nil:
return fmt.Errorf("(%dth iteration) Rand reader error: %s", i, err)
case n != len(buf):
// err is nil!!!
return fmt.Errorf("(%dth iteration) didn't get the bytes we requested (%d), got %d", i, len(buf), n)
default:
return nil
}
}
func main() {
for i := 0; i < 1000000; i++ {
if err := foo(i); err != nil {
panic(err)
}
}
}
The text was updated successfully, but these errors were encountered:
by byron.rakitzis:
The text was updated successfully, but these errors were encountered: