var (
codes = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/~!@#$%^&*()_="
codeLen = len(codes)
)
func RandNewStr(len int) string {
data := make([]byte, len)
rand.Seed(time.Now().UnixNano())
for i := 0; i < len; i++ {
idx := rand.Intn(codeLen)
data[i] = byte(codes[idx])
}
return string(data)
}
go生成随机字符串函数
发表回复