I have a deck of flashcards that I want to shuffle. Here's the method I'm using to shuffle them:
func (deck *Deck) Shuffle() {
rand.Seed(time.Now().UnixNano())
randomIndexes := rand.Perm(len(deck.Cards))
shuffledCards := make([]Card, len(deck.Cards))
for i := 0; i < len(deck.Cards); i++ {
shuffledCards[i] = deck.Cards[randomIndexes[i]]
}
deck.Cards = shuffledCards
}
Is this an efficient way of doing it, or is there a better way?