bump to Go 1.20 and rm deprecated rand.Seed
This commit is contained in:
@@ -3,6 +3,7 @@ package backend
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"log"
|
"log"
|
||||||
|
"math/rand"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/dweymouth/supersonic/backend/mediaprovider"
|
"github.com/dweymouth/supersonic/backend/mediaprovider"
|
||||||
@@ -180,7 +181,7 @@ func (p *PlaybackManager) LoadTracks(tracks []*mediaprovider.Track, appendToQueu
|
|||||||
}
|
}
|
||||||
nums := util.Range(len(tracks))
|
nums := util.Range(len(tracks))
|
||||||
if shuffle {
|
if shuffle {
|
||||||
util.ShuffleSlice(nums)
|
rand.Shuffle(len(nums), func(i, j int) { nums[i], nums[j] = nums[j], nums[i] })
|
||||||
}
|
}
|
||||||
for _, i := range nums {
|
for _, i := range nums {
|
||||||
url, err := p.sm.Server.GetStreamURL(tracks[i].ID, p.transcodeCfg.ForceRawFile)
|
url, err := p.sm.Server.GetStreamURL(tracks[i].ID, p.transcodeCfg.ForceRawFile)
|
||||||
|
|||||||
@@ -2,9 +2,7 @@ package util
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"io"
|
"io"
|
||||||
"math/rand"
|
|
||||||
"os"
|
"os"
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Return a slice of range [0, n)
|
// Return a slice of range [0, n)
|
||||||
@@ -16,11 +14,6 @@ func Range(n int) []int {
|
|||||||
return s
|
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] })
|
|
||||||
}
|
|
||||||
|
|
||||||
func CopyFile(srcPath, dstPath string) error {
|
func CopyFile(srcPath, dstPath string) error {
|
||||||
fin, err := os.Open(srcPath)
|
fin, err := os.Open(srcPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user