| 152 | ) |
| 153 | |
| 154 | func RandPath() string { |
| 155 | n := 16 |
| 156 | b := make([]byte, n) |
| 157 | // A rand.Int63() generates 63 random bits, enough for letterIdMax letters! |
| 158 | for i, cache, remain := n-1, randInt63(), letterIdMax; i >= 0; { |
| 159 | if remain == 0 { |
| 160 | cache, remain = randInt63(), letterIdMax |
| 161 | } |
| 162 | if idx := int(cache & letterIdMask); idx < len(letters) { |
| 163 | b[i] = letters[idx] |
| 164 | i-- |
| 165 | } |
| 166 | cache >>= letterIdBits |
| 167 | remain-- |
| 168 | } |
| 169 | return *(*string)(unsafe.Pointer(&b)) |
| 170 | } |
| 171 | |
| 172 | func RandHost() string { |
| 173 | n := 8 |