You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

utils.go 298 B

1 year ago
1234567891011121314151617181920
  1. package os2
  2. import (
  3. "math/rand"
  4. "strings"
  5. )
  6. func GenerateRandomFileName(len int) string {
  7. sb := strings.Builder{}
  8. for i := 0; i < len; i++ {
  9. rd := rand.Intn(26 + 10)
  10. if rd < 26 {
  11. sb.WriteRune('a' + rune(rd))
  12. } else {
  13. sb.WriteRune('0' + rune(rd-10))
  14. }
  15. }
  16. return sb.String()
  17. }