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

namegen.go 580B

12345678910111213141516171819202122232425262728293031323334
  1. package util
  2. import (
  3. "math/rand"
  4. "strings"
  5. )
  6. func Namegen() string {
  7. vowels := make([]string, 6)
  8. copy(vowels, strings.Split("aeiouy", ""))
  9. consonants := make([]string, 20)
  10. copy(consonants, strings.Split("bcdfghjklmnpqrstvwxz", ""))
  11. ln := rand.Intn(5) + 5
  12. vorc := rand.Intn(2)
  13. i := 0
  14. nm := make([]string, ln)
  15. for i < ln {
  16. sel, c := 0, ""
  17. if i%2 == vorc {
  18. sel = rand.Intn(6)
  19. c = vowels[sel]
  20. } else {
  21. sel = rand.Intn(20)
  22. c = consonants[sel]
  23. }
  24. if i == 0 {
  25. c = strings.ToUpper(c)
  26. }
  27. nm = append(nm, c)
  28. i++
  29. }
  30. return strings.Join(nm, "")
  31. }