wiki/util.go

23 lines
373 B
Go
Raw Normal View History

2018-11-24 12:34:51 +00:00
package main
import (
"math/rand"
2019-02-25 19:09:52 +00:00
"time"
2018-11-24 12:34:51 +00:00
)
2019-02-25 19:09:52 +00:00
var random *rand.Rand
func init() {
random = rand.New(rand.NewSource(time.Now().UnixNano()))
}
2018-11-24 12:34:51 +00:00
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)
}