mirror of
https://github.com/MontFerret/ferret.git
synced 2025-01-18 03:22:02 +02:00
#496_fix_RandomToken_on_Windows (#497)
This commit is contained in:
parent
f6b64c9294
commit
9dd35add2c
@ -17,6 +17,10 @@ const (
|
||||
letterIdxMax = 63 / letterIdxBits // # of letter indices fitting in 63 bits
|
||||
)
|
||||
|
||||
// randSrc is a global variable because of this issue
|
||||
// https://github.com/golang/go/issues/8926
|
||||
var randSrc = rand.NewSource(time.Now().UnixNano())
|
||||
|
||||
// RandomToken generates a pseudo-random token string with the specified length. The algorithm for token generation should be treated as opaque.
|
||||
// @param length (Int) - The desired string length for the token. It must be greater than 0 and at most 65536.
|
||||
// @return (String) - A generated token consisting of lowercase letters, uppercase letters and numbers.
|
||||
@ -34,8 +38,6 @@ func RandomToken(_ context.Context, args ...core.Value) (core.Value, error) {
|
||||
}
|
||||
|
||||
size := args[0].(values.Int)
|
||||
randSrc := rand.NewSource(time.Now().UnixNano())
|
||||
|
||||
b := make([]byte, size)
|
||||
|
||||
for i, cache, remain := size-1, randSrc.Int63(), letterIdxMax; i >= 0; {
|
||||
|
Loading…
x
Reference in New Issue
Block a user