(length int)
| 57 | const chars string = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" |
| 58 | |
| 59 | func genRandomCode(length int) (string, error) { |
| 60 | id := "" |
| 61 | for i := 0; i < length; i++ { |
| 62 | randIndex, err := rand.Int(rand.Reader, big.NewInt(int64(len(chars)))) |
| 63 | if err != nil { |
| 64 | return "", err |
| 65 | } |
| 66 | id += string(chars[randIndex.Int64()]) |
| 67 | } |
| 68 | return id, nil |
| 69 | } |
| 70 | |
| 71 | func randomOpenPort() (int, error) { |
| 72 | listener, err := net.Listen("tcp", "127.0.0.1:0") |
no outgoing calls
no test coverage detected