rand.go 337 B

12345678910111213141516171819
  1. package util
  2. import "math/rand"
  3. var letterRunes = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
  4. // RandID .
  5. func RandID() int64 {
  6. return rand.Int63()
  7. }
  8. // RandStr .
  9. func RandStr(size int) string {
  10. b := make([]rune, size)
  11. for i := range b {
  12. b[i] = letterRunes[rand.Intn(len(letterRunes))]
  13. }
  14. return string(b)
  15. }