be9a64a41b
schemas / vulnerabilities (push) Successful in 2m8s
schemas / check (push) Successful in 2m39s
Release / release (push) Successful in 55s
schemas / check-release (push) Successful in 2m56s
pre-commit / pre-commit (push) Successful in 7m18s
schemas / build (push) Successful in 8m0s
schemas / deploy-prod (push) Successful in 1m11s
26 lines
473 B
Go
26 lines
473 B
Go
package rand
|
|
|
|
import (
|
|
"math/rand"
|
|
"time"
|
|
)
|
|
|
|
const charset = "abcdefghijklmnopqrstuvwxyz" +
|
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
|
|
|
|
var seededRand *rand.Rand = rand.New(
|
|
rand.NewSource(time.Now().UnixNano()),
|
|
)
|
|
|
|
func StringWithCharset(length int, charset string) string {
|
|
b := make([]byte, length)
|
|
for i := range b {
|
|
b[i] = charset[seededRand.Intn(len(charset))]
|
|
}
|
|
return string(b)
|
|
}
|
|
|
|
func String(length int) string {
|
|
return StringWithCharset(length, charset)
|
|
}
|