misc: Upgrade Go to v1.21

Upgrade to 1.21 as 1.20 is now unmaintained.

Most changes are related to the new `slices` package from standard
library, which can replace some existing custom functions.
This commit is contained in:
Michael Manganiello
2024-03-05 09:49:10 -03:00
parent ea1b2f3284
commit 801967a530
19 changed files with 47 additions and 104 deletions
+2 -2
View File
@@ -8,12 +8,12 @@ import (
"os"
"path"
"reflect"
"slices"
"time"
"github.com/dweymouth/supersonic/backend/player"
"github.com/dweymouth/supersonic/backend/player/mpv"
"github.com/dweymouth/supersonic/backend/util"
"github.com/dweymouth/supersonic/sharedutil"
"github.com/fsnotify/fsnotify"
"github.com/google/uuid"
@@ -233,7 +233,7 @@ func (a *App) setupMPV() error {
a.LocalPlayer.SetAudioDevice(desiredDevice)
rgainOpts := []string{ReplayGainNone, ReplayGainAlbum, ReplayGainTrack, ReplayGainAuto}
if !sharedutil.SliceContains(rgainOpts, a.Config.ReplayGain.Mode) {
if !slices.Contains(rgainOpts, a.Config.ReplayGain.Mode) {
a.Config.ReplayGain.Mode = ReplayGainNone
}
mode := player.ReplayGainNone
+1 -3
View File
@@ -64,9 +64,7 @@ func (r *baseIter[T]) Next() *T {
}
r.serverPos += len(items)
if !r.filter.IsNil() {
items = sharedutil.FilterSlice(items, func(al *T) bool {
return r.filter.Matches(al)
})
items = sharedutil.FilterSlice(items, r.filter.Matches)
}
r.prefetched = items
if len(items) > 0 {
-9
View File
@@ -5,15 +5,6 @@ import (
"os"
)
// 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 CopyFile(srcPath, dstPath string) error {
fin, err := os.Open(srcPath)
if err != nil {