2019-08-29 16:52:40 -04:00
|
|
|
package testutil // import "github.com/docker/docker/testutil"
|
2017-10-27 20:28:19 -04:00
|
|
|
|
|
|
|
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 {
|
2021-04-16 10:03:57 -04:00
|
|
|
b[i] = letters[rand.Intn(len(letters))] //nolint: gosec // G404: Use of weak random number generator (math/rand instead of crypto/rand)
|
2017-10-27 20:28:19 -04:00
|
|
|
}
|
|
|
|
return string(b)
|
|
|
|
}
|