Simplify reading from rand.
This commit is contained in:
parent
23e72bb56d
commit
7f58d67fe3
@ -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))
|
||||||
|
Loading…
Reference in New Issue
Block a user