File size: 382 Bytes
6fefda3 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
package utils
import (
"math/rand"
"time"
)
var randSource = rand.New(rand.NewSource(time.Now().UnixNano()))
func RandStringUsingMathRand(n int) string {
var letters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789")
result := make([]rune, n)
for i := 0; i < n; i++ {
result[i] = letters[randSource.Intn(len(letters))]
}
return string(result)
}
|