diff --git a/core/artwork/cache_warmer.go b/core/artwork/cache_warmer.go index f68db1a96..23cfe86b9 100644 --- a/core/artwork/cache_warmer.go +++ b/core/artwork/cache_warmer.go @@ -4,6 +4,8 @@ import ( "context" "fmt" "io" + "maps" + "slices" "sync" "time" @@ -14,7 +16,6 @@ import ( "github.com/navidrome/navidrome/model/request" "github.com/navidrome/navidrome/utils/cache" "github.com/navidrome/navidrome/utils/pl" - "golang.org/x/exp/maps" ) type CacheWarmer interface { @@ -94,7 +95,7 @@ func (a *cacheWarmer) run(ctx context.Context) { continue } - batch := maps.Keys(a.buffer) + batch := slices.Collect(maps.Keys(a.buffer)) a.buffer = make(map[model.ArtworkID]struct{}) a.mutex.Unlock() diff --git a/core/playback/queue.go b/core/playback/queue.go index b8017c6eb..a452b499d 100644 --- a/core/playback/queue.go +++ b/core/playback/queue.go @@ -114,7 +114,7 @@ func (pd *Queue) getMediaFileIndexByID(id string) (int, error) { return idx, nil } } - return -1, fmt.Errorf("ID not found in playlist: " + id) + return -1, fmt.Errorf("ID not found in playlist: %s", id) } // Sets the index to a new, valid value inside the Items. Values lower than zero are going to be zero, diff --git a/go.mod b/go.mod index 02c837784..6899973f4 100644 --- a/go.mod +++ b/go.mod @@ -1,8 +1,10 @@ module github.com/navidrome/navidrome +// This must match the ci-goreleaser Go version go 1.22 -toolchain go1.22.3 +// This is the version used by the project +toolchain go1.23.0 require ( github.com/Masterminds/squirrel v1.5.4 diff --git a/scanner/refresher.go b/scanner/refresher.go index 62d48bc73..3c87018c1 100644 --- a/scanner/refresher.go +++ b/scanner/refresher.go @@ -3,7 +3,9 @@ package scanner import ( "context" "fmt" + "maps" "path/filepath" + "slices" "strings" "time" @@ -13,7 +15,6 @@ import ( "github.com/navidrome/navidrome/log" "github.com/navidrome/navidrome/model" "github.com/navidrome/navidrome/utils/slice" - "golang.org/x/exp/maps" ) // refresher is responsible for rolling up mediafiles attributes into albums attributes, @@ -71,7 +72,7 @@ func (r *refresher) flushMap(ctx context.Context, m map[string]struct{}, entity return nil } - ids := maps.Keys(m) + ids := slices.Collect(maps.Keys(m)) chunks := slice.BreakUp(ids, 100) for _, chunk := range chunks { err := refresh(ctx, chunk...) diff --git a/tests/mock_mediafile_repo.go b/tests/mock_mediafile_repo.go index 63f1eda06..11d6a0f0f 100644 --- a/tests/mock_mediafile_repo.go +++ b/tests/mock_mediafile_repo.go @@ -2,13 +2,13 @@ package tests import ( "errors" + "maps" + "slices" "time" "github.com/google/uuid" - "github.com/navidrome/navidrome/utils/slice" - "golang.org/x/exp/maps" - "github.com/navidrome/navidrome/model" + "github.com/navidrome/navidrome/utils/slice" ) func CreateMockMediaFileRepo() *MockMediaFileRepo { @@ -56,7 +56,7 @@ func (m *MockMediaFileRepo) GetAll(...model.QueryOptions) (model.MediaFiles, err if m.err { return nil, errors.New("error") } - values := maps.Values(m.data) + values := slices.Collect(maps.Values(m.data)) return slice.Map(values, func(p *model.MediaFile) model.MediaFile { return *p }), nil diff --git a/utils/merge/merge_fs.go b/utils/merge/merge_fs.go index cbb568707..b3b02e55b 100644 --- a/utils/merge/merge_fs.go +++ b/utils/merge/merge_fs.go @@ -5,9 +5,8 @@ import ( "errors" "io" "io/fs" + "maps" "slices" - - "golang.org/x/exp/maps" ) // FS implements a simple merged fs.FS, that can combine a Base FS with an Overlay FS. The semantics are: @@ -64,9 +63,8 @@ func (m FS) mergeDirs(name string, info fs.FileInfo, baseDir fs.ReadDirFile, ove for _, f := range overlayFiles { merged[f.Name()] = f } - entries := maps.Values(merged) - - slices.SortFunc(entries, func(i, j fs.DirEntry) int { return cmp.Compare(i.Name(), j.Name()) }) + it := maps.Values(merged) + entries := slices.SortedFunc(it, func(i, j fs.DirEntry) int { return cmp.Compare(i.Name(), j.Name()) }) return &mergedDir{ name: name, info: info,