mirror of
https://github.com/HChaZZY/alist.git
synced 2025-12-21 17:46:28 +08:00
chore: move conf package
This commit is contained in:
23
pkg/utils/random.go
Normal file
23
pkg/utils/random.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
"time"
|
||||
)
|
||||
|
||||
var Rand *rand.Rand
|
||||
|
||||
const letterBytes = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
|
||||
|
||||
func RandomStr(n int) string {
|
||||
b := make([]byte, n)
|
||||
for i := range b {
|
||||
b[i] = letterBytes[Rand.Intn(len(letterBytes))]
|
||||
}
|
||||
return string(b)
|
||||
}
|
||||
|
||||
func init() {
|
||||
s := rand.NewSource(time.Now().UnixNano())
|
||||
Rand = rand.New(s)
|
||||
}
|
||||
Reference in New Issue
Block a user