- refactored User service from IceWhaleTech/CasaOS as first modularized service
This commit is contained in:
Tiger Wang (王豫)
2022-08-04 19:14:53 -04:00
committed by GitHub
parent a71dd10757
commit e2b617e510
23 changed files with 1870 additions and 1 deletions
+24
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)
}