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
27 lines
466 B
package lottery_service
|
|
|
|
import (
|
|
"math/rand"
|
|
"time"
|
|
)
|
|
|
|
type LotteryUser struct {
|
|
UserId int64
|
|
Username string
|
|
UserPhone string
|
|
Avatar string
|
|
PrizeName string
|
|
LadderId int64
|
|
PrizeImg string
|
|
}
|
|
|
|
func RandLotteryUser(users []*LotteryUser) {
|
|
r := rand.New(rand.Source(rand.NewSource(time.Now().Unix())))
|
|
if len(users) <= 0 {
|
|
return
|
|
}
|
|
for i := len(users) - 1; i > 0; i-- {
|
|
num := r.Intn(i + 1)
|
|
users[i], users[num] = users[num], users[i]
|
|
}
|
|
}
|