mirror of
https://github.com/go-gitea/gitea
synced 2024-09-27 11:39:06 +02:00
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
|
||
|
}
|