package HyTools import ( "math/rand" "time" ) func RandInt64(min, max int64) int64 { if min >= max || min == 0 || max == 0 { return max } return rand.Int63n(max-min) + min } // 获取随机数字字符串 func GetRandNumber(l int) string { str := "0123456789" bytes := []byte(str) result := []byte{} r := rand.New(rand.NewSource(time.Now().UnixNano())) for i := 0; i < l; i++ { result = append(result, bytes[r.Intn(len(bytes))]) } return string(result) } // 生成随机字符串 func GetRandomString(l int) string { str := "0123456789abcdefghijklmnopqrstuvwxyz" bytes := []byte(str) result := []byte{} r := rand.New(rand.NewSource(time.Now().UnixNano())) for i := 0; i < l; i++ { result = append(result, bytes[r.Intn(len(bytes))]) } return string(result) }