MCPcopy Create free account
hub / github.com/Azure/peerd / newRandomString

Function newRandomString

pkg/cache/main_test.go:45–60  ·  view source on GitHub ↗

newRandomString creates a new random string.

()

Source from the content-addressed store, hash-verified

43
44// newRandomString creates a new random string.
45func newRandomString() string {
46 const blockSize = 1024 * 1024
47 r, err := rand.Int(rand.Reader, big.NewInt(4))
48 if err != nil {
49 panic(err)
50 }
51 length := r.Int64() * blockSize
52
53 r, err = rand.Int(rand.Reader, big.NewInt(blockSize))
54 if err != nil {
55 panic(err)
56 }
57 length += r.Int64()
58
59 return newRandomStringN(int(length))
60}
61
62// newRandomStringN creates a new random string of length n.
63func newRandomStringN(n int) string {

Callers 2

TestExistsFunction · 0.85
TestGetOrCreateFunction · 0.85

Calls 1

newRandomStringNFunction · 0.70

Tested by

no test coverage detected