mirror of
https://github.com/rclone/rclone.git
synced 2024-12-02 05:14:55 +01:00
23 lines
552 B
Go
23 lines
552 B
Go
|
// Package random holds a few functions for working with random numbers
|
||
|
package random
|
||
|
|
||
|
import "math/rand"
|
||
|
|
||
|
// String create a random string for test purposes
|
||
|
func String(n int) string {
|
||
|
const (
|
||
|
vowel = "aeiou"
|
||
|
consonant = "bcdfghjklmnpqrstvwxyz"
|
||
|
digit = "0123456789"
|
||
|
)
|
||
|
pattern := []string{consonant, vowel, consonant, vowel, consonant, vowel, consonant, digit}
|
||
|
out := make([]byte, n)
|
||
|
p := 0
|
||
|
for i := range out {
|
||
|
source := pattern[p]
|
||
|
p = (p + 1) % len(pattern)
|
||
|
out[i] = source[rand.Intn(len(source))]
|
||
|
}
|
||
|
return string(out)
|
||
|
}
|