MCPcopy Index your code
hub / github.com/cortexlabs/cortex / randomString

Function randomString

pkg/lib/random/random.go:36–51  ·  view source on GitHub ↗
(n int, src rand.Source, charset string)

Source from the content-addressed store, hash-verified

34)
35
36func randomString(n int, src rand.Source, charset string) string {
37 b := make([]byte, n)
38 for i, cache, remain := n-1, src.Int63(), _letterIdxMax; i >= 0; {
39 if remain == 0 {
40 cache, remain = src.Int63(), _letterIdxMax
41 }
42 if idx := int(cache & _letterIdxMask); idx < len(charset) {
43 b[i] = charset[idx]
44 i--
45 }
46 cache >>= _letterIdxBits
47 remain--
48 }
49
50 return string(b)
51}
52
53// Digits generates a random string containing only digits
54func Digits(n int) string {

Callers 5

DigitsFunction · 0.85
LettersFunction · 0.85
LowercaseLettersFunction · 0.85
StringFunction · 0.85
LowercaseStringFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected