package util import "crypto/rand" const charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" func RandomString(length int) (string, error) { bytes := make([]byte, length) _, err := rand.Read(bytes) if err != nil { return "", err } for i := range bytes { bytes[i] = charset[int(bytes[i])%len(charset)] } return string(bytes), nil }