package unity import ( "math/rand" "time" ) // RandomId 生成32位随机id func RandomId() string { const letterBytes = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" rand.Seed(time.Now().UnixNano()) b := make([]byte, 8) for i := range b { b[i] = letterBytes[rand.Intn(len(letterBytes))] } return string(b) } func RandomIds(lenght int) string { const letterBytes = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" rand.Seed(time.Now().UnixNano()) b := make([]byte, lenght) for i := range b { b[i] = letterBytes[rand.Intn(len(letterBytes))] } return string(b) } // RandomAppID 生成12位随机appid func RandomAppID() string { const letterBytes = "0123456789" rand.Seed(time.Now().UnixNano()) b := make([]byte, 12) for i := range b { b[i] = letterBytes[rand.Intn(len(letterBytes))] } return string(b) }