Also document the panic to be consistent with math/rand.
Fixes #5187.
R=golang-dev, dave, bradfitz, r
CC=golang-dev
https://golang.org/cl/
8303043
}
}
-// Int returns a uniform random value in [0, max).
+// Int returns a uniform random value in [0, max). It panics if max <= 0.
func Int(rand io.Reader, max *big.Int) (n *big.Int, err error) {
+ if max.Sign() <= 0 {
+ panic("crypto/rand: argument to Int is <= 0")
+ }
k := (max.BitLen() + 7) / 8
// b is the number of bits in the most significant byte of max.