Files
opencloud/vendor/github.com/gookit/goutil/strutil/random_nonwin.go
dependabot[bot] 452d40dad7 build(deps): bump github.com/gookit/config/v2 from 2.2.5 to 2.2.6
Bumps [github.com/gookit/config/v2](https://github.com/gookit/config) from 2.2.5 to 2.2.6.
- [Release notes](https://github.com/gookit/config/releases)
- [Commits](https://github.com/gookit/config/compare/v2.2.5...v2.2.6)

---
updated-dependencies:
- dependency-name: github.com/gookit/config/v2
  dependency-version: 2.2.6
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-04-29 14:15:29 +00: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)
}