You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
324 B
Go
20 lines
324 B
Go
package etcd
|
|
|
|
import (
|
|
"math/rand"
|
|
)
|
|
|
|
func shuffleStringSlice(cards []string) []string {
|
|
size := len(cards)
|
|
//Do not need to copy if nothing changed
|
|
if size <= 1 {
|
|
return cards
|
|
}
|
|
shuffled := make([]string, size)
|
|
index := rand.Perm(size)
|
|
for i := range cards {
|
|
shuffled[index[i]] = cards[i]
|
|
}
|
|
return shuffled
|
|
}
|