randomId.go 310 B

1234567891011121314151617
  1. package unity
  2. import (
  3. "math/rand"
  4. "time"
  5. )
  6. func RandomId() string {
  7. const letterBytes = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
  8. rand.Seed(time.Now().UnixNano())
  9. b := make([]byte, 32)
  10. for i := range b {
  11. b[i] = letterBytes[rand.Intn(len(letterBytes))]
  12. }
  13. return string(b)
  14. }