Files
QSfera/Server/vendor/github.com/gookit/goutil/strutil/random_nonwin.go
T
Курнат Андрей 2315f25754 Initial QSfera import
2026-06-07 10:20:04 +03:00

28 lines
451 B
Go

//go:build !windows
package strutil
import (
"math/rand"
"time"
)
var rn = newRand()
func newRand() *rand.Rand {
return rand.New(rand.NewSource(time.Now().UnixNano()))
}
// buildRandomString 生成随机字符串
func buildRandomString(letters string, length int) string {
// rn := newRand()
cs := make([]byte, length)
lettersN := len(letters)
for i := 0; i < length; i++ {
cs[i] = letters[rn.Intn(lettersN)]
}
return Byte2str(cs)
}