mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
7c35a24182
Signed-off-by: chaowang <chaowang@localhost.localdomain>
14 lines
389 B
Go
14 lines
389 B
Go
package testutil
|
|
|
|
import "math/rand"
|
|
|
|
// GenerateRandomAlphaOnlyString generates an alphabetical random string with length n.
|
|
func GenerateRandomAlphaOnlyString(n int) string {
|
|
// make a really long string
|
|
letters := []byte("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
|
|
b := make([]byte, n)
|
|
for i := range b {
|
|
b[i] = letters[rand.Intn(len(letters))]
|
|
}
|
|
return string(b)
|
|
}
|