govote/utils/random.go
2024-05-13 10:45:38 +02:00

15 lines
307 B
Go

package utils
import (
"math/rand"
)
const charSet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
func GenerateRandomString(length int) string {
result := make([]byte, length)
for i := 0; i < length; i++ {
result[i] = charSet[rand.Intn(len(charSet))]
}
return string(result)
}