Simplify reading from rand.

This commit is contained in:
Dmitry Chestnykh 2011-04-05 20:37:41 +02:00
parent 23e72bb56d
commit 7f58d67fe3

View File

@ -44,7 +44,7 @@ func NewLen(length int) string {
// of the provided byte slice of allowed characters (maximum 256). // of the provided byte slice of allowed characters (maximum 256).
func NewLenChars(length int, chars []byte) string { func NewLenChars(length int, chars []byte) string {
b := make([]byte, length) b := make([]byte, length)
if _, err := rand.Reader.Read(b); err != nil { if _, err := rand.Read(b); err != nil {
panic("error reading from random source: " + err.String()) panic("error reading from random source: " + err.String())
} }
alen := byte(len(chars)) alen := byte(len(chars))