govote/utils/random.go

16 lines
307 B
Go
Raw Normal View History

2024-05-13 00:47:24 +02:00
package utils
import (
"math/rand"
)
const charSet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
func GenerateRandomString(length int) string {
2024-05-13 10:45:38 +02:00
result := make([]byte, length)
for i := 0; i < length; i++ {
result[i] = charSet[rand.Intn(len(charSet))]
}
return string(result)
2024-05-13 00:47:24 +02:00
}