wiki/util.go
Peter Stuifzand 3a7cf081f0
All checks were successful
the build was successful
Use random Seed
2019-02-25 20:09:52 +01:00

23 lines
373 B
Go

package main
import (
"math/rand"
"time"
)
var random *rand.Rand
func init() {
random = rand.New(rand.NewSource(time.Now().UnixNano()))
}
const letterBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
func RandStringBytes(n int) string {
b := make([]byte, n)
for i := range b {
b[i] = letterBytes[rand.Intn(len(letterBytes))]
}
return string(b)
}