互动
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
466 B

5 years ago
  1. package lottery_service
  2. import (
  3. "math/rand"
  4. "time"
  5. )
  6. type LotteryUser struct {
  7. UserId int64
  8. Username string
  9. UserPhone string
  10. Avatar string
  11. PrizeName string
  12. LadderId int64
  13. PrizeImg string
  14. }
  15. func RandLotteryUser(users []*LotteryUser) {
  16. r := rand.New(rand.Source(rand.NewSource(time.Now().Unix())))
  17. if len(users) <= 0 {
  18. return
  19. }
  20. for i := len(users) - 1; i > 0; i-- {
  21. num := r.Intn(i + 1)
  22. users[i], users[num] = users[num], users[i]
  23. }
  24. }