package main import ( "crypto/rand" ) const ( alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" ) // RandomString ... func RandomString(length int) string { bytes := make([]byte, length) rand.Read(bytes) for i, b := range bytes { bytes[i] = alphabet[b%byte(len(alphabet))] } return string(bytes) }