mirror of
https://github.com/mudler/LocalAI.git
synced 2024-12-19 04:37:53 +00:00
21 lines
328 B
Go
21 lines
328 B
Go
|
package utils
|
||
|
|
||
|
import (
|
||
|
"math/rand"
|
||
|
"time"
|
||
|
)
|
||
|
|
||
|
var letterRunes = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
|
||
|
|
||
|
func init() {
|
||
|
rand.Seed(time.Now().UnixNano())
|
||
|
}
|
||
|
|
||
|
func RandString(n int) string {
|
||
|
b := make([]rune, n)
|
||
|
for i := range b {
|
||
|
b[i] = letterRunes[rand.Intn(len(letterRunes))]
|
||
|
}
|
||
|
return string(b)
|
||
|
}
|