(n int, src rand.Source, charset string)
| 34 | ) |
| 35 | |
| 36 | func 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 |
| 54 | func Digits(n int) string { |
no outgoing calls
no test coverage detected