12345678910111213141516 |
- package utils
- import (
- "math/rand"
- "time"
- )
- func RandomString(length int) string {
- chars := "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
- r := rand.New(rand.NewSource(time.Now().UnixNano()))
- b := make([]byte, length)
- for i := range b {
- b[i] = chars[r.Intn(len(chars))]
- }
- return string(b)
- }
|