pkg: remove random package

The unnecessary `random` package has been removed in favor of using the
`math/rand` package directly. Seeding of the random value from crypto
has been added to the `stringid` package to account for the change.

May need to add an equivalent seed to `namesgenerator`, but this is
often used with `stringid` and has collision protection.

Signed-off-by: Stephen J Day <stephen.day@docker.com>
Upstream-commit: 66cfe61f71252f528ddb458d554cd241e996d9f1
Component: engine
This commit is contained in:
Stephen J Day
2017-05-08 17:02:02 -07:00
parent cf964b3db2
commit 957a7e39a2
5 changed files with 32 additions and 111 deletions

View File

@ -5,8 +5,6 @@ import (
"bytes"
"math/rand"
"strings"
"github.com/docker/docker/pkg/random"
)
// GenerateRandomAlphaOnlyString generates an alphabetical random string with length n.
@ -15,7 +13,7 @@ func GenerateRandomAlphaOnlyString(n int) string {
letters := []byte("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
b := make([]byte, n)
for i := range b {
b[i] = letters[random.Rand.Intn(len(letters))]
b[i] = letters[rand.Intn(len(letters))]
}
return string(b)
}