diff --git a/main.go b/main.go index 6eb9315..2cda9de 100644 --- a/main.go +++ b/main.go @@ -30,11 +30,6 @@ type redisPoolConf struct { } const letterBytes = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" -const ( - letterIdxBits = 6 // 6 bits to represent a letter index - letterIdxMask = 1<= 0; { - if remain == 0 { - cache, remain = rand.Int63(), letterIdxMax - } - if idx := int(cache & letterIdxMask); idx < len(letterBytes) { - b[i] = letterBytes[idx] - i-- - } - cache >>= letterIdxBits - remain-- + currentTime := time.Now().Unix() + for i := range b { + b[i] = letterBytes[(currentTime + rand.Int63()) % int64(len(letterBytes))] } - return string(b) }