add shuffle button to album and playlist pages

This commit is contained in:
Drew Weymouth
2023-02-15 19:46:08 -08:00
parent 76828ecf5e
commit aa2204b88f
32 changed files with 123 additions and 44 deletions
+20
View File
@@ -0,0 +1,20 @@
package util
import (
"math/rand"
"time"
)
// Return a slice of range [0, n)
func Range(n int) []int {
s := make([]int, n)
for i := 0; i < n; i++ {
s[i] = i
}
return s
}
func ShuffleSlice(a []int) {
rand.Seed(time.Now().UnixNano())
rand.Shuffle(len(a), func(i, j int) { a[i], a[j] = a[j], a[i] })
}