1
0
mirror of https://github.com/IceWhaleTech/CasaOS.git synced 2025-07-06 23:37:26 +02:00

first commit

This commit is contained in:
a624669980
2021-09-26 10:35:02 +08:00
commit 7fb9bd1d06
195 changed files with 36650 additions and 0 deletions

View File

@ -0,0 +1,24 @@
package random
import (
"math/rand"
"time"
)
func RandomString(n int, onlyLetter bool) string {
var letters []rune
if onlyLetter {
letters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
} else {
letters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789")
}
b := make([]rune, n)
rand.Seed(time.Now().UnixNano())
for i := range b {
b[i] = letters[rand.Intn(len(letters))]
}
return string(b)
}