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:
@@ -2,7 +2,7 @@ package widgets
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sort"
|
||||
"slices"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
@@ -49,7 +49,7 @@ func NewAlbumFilterButton(filter *mediaprovider.AlbumFilter, fetchGenresFunc fun
|
||||
genreNames := sharedutil.MapSlice(genres, func(g *mediaprovider.Genre) string {
|
||||
return g.Name
|
||||
})
|
||||
sort.Strings(genreNames)
|
||||
slices.Sort(genreNames)
|
||||
a.genreListChan <- genreNames
|
||||
}
|
||||
}()
|
||||
|
||||
@@ -3,9 +3,9 @@ package widgets
|
||||
import (
|
||||
"image"
|
||||
"image/color"
|
||||
"slices"
|
||||
|
||||
"github.com/dweymouth/supersonic/res"
|
||||
"github.com/dweymouth/supersonic/sharedutil"
|
||||
"github.com/dweymouth/supersonic/ui/layouts"
|
||||
"github.com/dweymouth/supersonic/ui/util"
|
||||
|
||||
@@ -205,7 +205,7 @@ func (g *GridViewItem) createContainer() {
|
||||
}
|
||||
|
||||
func (g *GridViewItem) NeedsUpdate(model GridViewItemModel) bool {
|
||||
return g.itemID != model.ID || !sharedutil.SliceEqual(g.secondaryIDs, model.SecondaryIDs)
|
||||
return g.itemID != model.ID || !slices.Equal(g.secondaryIDs, model.SecondaryIDs)
|
||||
}
|
||||
|
||||
func (g *GridViewItem) Update(model GridViewItemModel) {
|
||||
|
||||
@@ -3,6 +3,7 @@ package widgets
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"slices"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -271,7 +272,7 @@ func (t *Tracklist) Sorting() TracklistSort {
|
||||
func (t *Tracklist) SetSorting(sorting TracklistSort) {
|
||||
if sorting.ColumnName == "" {
|
||||
// nil case - reset current sort
|
||||
if sharedutil.SliceContains(columns, t.sorting.ColumnName) {
|
||||
if slices.Contains(columns, t.sorting.ColumnName) {
|
||||
t.hdr.SetSorting(ListHeaderSort{ColNumber: ColNumber(t.sorting.ColumnName), Type: SortNone})
|
||||
}
|
||||
return
|
||||
@@ -667,7 +668,7 @@ func (t *Tracklist) lenTracks() int {
|
||||
}
|
||||
|
||||
func ColNumber(colName string) int {
|
||||
i := sharedutil.IndexOf(columns, colName)
|
||||
i := slices.Index(columns, colName)
|
||||
if i < 0 {
|
||||
log.Printf("error: Tracklist: invalid column name %s", colName)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user