mirror of
https://github.com/moby/moby.git
synced 2026-08-12 22:16:46 +00:00
- use math/rand/v2 - change the util to only produce lowercase; some tests only could use lowercase, and we don't need uppercase here, as long as it's random. - drop the Uniqueness test; it was effectively just testing stdlib functionality (math/rand/v2 to be random). - rename to RandomAlpha while we had to update call-sites Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
15 lines
420 B
Go
15 lines
420 B
Go
package testutil
|
|
|
|
import "math/rand/v2"
|
|
|
|
const letters = "abcdefghijklmnopqrstuvwxyz"
|
|
|
|
// RandomAlpha generates a lowercase alphabetical random string with length n.
|
|
func RandomAlpha(n int) string {
|
|
b := make([]byte, n)
|
|
for i := range b {
|
|
b[i] = letters[rand.IntN(len(letters))] // #nosec G404 -- ignore "Use of weak random number generator (math/rand or math/rand/v2 instead of crypto/rand)"
|
|
}
|
|
return string(b)
|
|
}
|