Merge 0fd48dc60e into 53e2fd7421
This commit is contained in:
commit
0ed582b1dd
1 changed files with 5 additions and 1 deletions
|
|
@ -51,6 +51,8 @@ func NewLenChars(length int, chars []byte) string {
|
||||||
clen := byte(len(chars))
|
clen := byte(len(chars))
|
||||||
maxrb := byte(256 - (256 % len(chars)))
|
maxrb := byte(256 - (256 % len(chars)))
|
||||||
i := 0
|
i := 0
|
||||||
|
var ret string
|
||||||
|
OuterLoop:
|
||||||
for {
|
for {
|
||||||
if _, err := io.ReadFull(rand.Reader, r); err != nil {
|
if _, err := io.ReadFull(rand.Reader, r); err != nil {
|
||||||
panic("error reading from random source: " + err.Error())
|
panic("error reading from random source: " + err.Error())
|
||||||
|
|
@ -63,8 +65,10 @@ func NewLenChars(length int, chars []byte) string {
|
||||||
b[i] = chars[c%clen]
|
b[i] = chars[c%clen]
|
||||||
i++
|
i++
|
||||||
if i == length {
|
if i == length {
|
||||||
return string(b)
|
ret = string(b)
|
||||||
|
break OuterLoop
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return ret
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue