fix return for old go version
This commit is contained in:
parent
53e2fd7421
commit
0fd48dc60e
@ -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…
Reference in New Issue
Block a user