🎧 Your Personal Streaming Service
Go airsonicmadsonicmedia-servermusicmusic-servernavidromeopensubsonicraspberry-piself-hostedstreamerstreaming-apistreaming-audiosubsonicsubsonic-server
chore: go fix
Deluan2a43c4683ea4
diff --git a/cmd/inspect.go b/cmd/inspect.goindex 9f9270b1e..5e88793cc 100644--- a/cmd/inspect.go+++ b/cmd/inspect.go@@ -32,17 +32,17 @@ var inspectCmd = &cobra.Command{},}-var marshalers = map[string]func(interface{}) ([]byte, error){+var marshalers = map[string]func(any) ([]byte, error){"pretty": prettyMarshal,"toml": toml.Marshal,"yaml": yaml.Marshal,"json": json.Marshal,- "jsonindent": func(v interface{}) ([]byte, error) {+ "jsonindent": func(v any) ([]byte, error) {return json.MarshalIndent(v, "", " ")},}-func prettyMarshal(v interface{}) ([]byte, error) {+func prettyMarshal(v any) ([]byte, error) {out := v.([]core.InspectOutput)var res strings.Builderfor i := range out {diff --git a/core/artwork/benchmark_e2e_test.go b/core/artwork/benchmark_e2e_test.goindex 393cbb473..bf3d435a8 100644--- a/core/artwork/benchmark_e2e_test.go+++ b/core/artwork/benchmark_e2e_test.go@@ -169,7 +169,7 @@ func BenchmarkArtworkGetE2EConcurrent(b *testing.B) {for i := 0; i < b.N; i++ {var wg sync.WaitGroupwg.Add(n)- for g := 0; g < n; g++ {+ for range n {go func() {defer wg.Done()r, _, err := aw.Get(context.Background(), artID, 300, true)diff --git a/core/artwork/benchmark_helpers_test.go b/core/artwork/benchmark_helpers_test.goindex 60990bb8b..0076506f3 100644--- a/core/artwork/benchmark_helpers_test.go+++ b/core/artwork/benchmark_helpers_test.go@@ -35,8 +35,8 @@ func generatePNG(t testing.TB, width, height int) []byte {// generateGradientImage creates an RGBA image with a diagonal gradient pattern.func generateGradientImage(width, height int) *image.RGBA {img := image.NewRGBA(image.Rect(0, 0, width, height))- for y := 0; y < height; y++ {- for x := 0; x < width; x++ {+ for y := range height {+ for x := range width {r := uint8((x * 255) / width)g := uint8((y * 255) / height)b := uint8(((x + y) * 255) / (width + height))diff --git a/core/ffmpeg/ffmpeg.go b/core/ffmpeg/ffmpeg.goindex a3f6cd7d2..58e9fd152 100644--- a/core/ffmpeg/ffmpeg.go+++ b/core/ffmpeg/ffmpeg.go@@ -496,8 +496,8 @@ func createFFmpegCommand(cmd, path string, maxBitRate, offset int) []string {// Pre-input seeking: ffmpeg seeks at the demuxer level (fast)// instead of decoding all frames up to the offset (slow).insertAt := len(args)- for i := len(args) - 1; i >= 0; i-- {- if args[i] == "-i" {+ for i, arg := range slices.Backward(args) {+ if arg == "-i" {insertAt = ibreak}diff --git a/core/share.go b/core/share.goindex eb9b63ae9..5a611c7f0 100644--- a/core/share.go+++ b/core/share.go@@ -98,7 +98,7 @@ func (r *shareRepositoryWrapper) Save(entity any) (string, error) {s.ExpiresAt = new(time.Now().Add(conf.Server.DefaultShareExpiration))}- firstId := strings.SplitN(s.ResourceIDs, ",", 2)[0]+ firstId, _, _ := strings.Cut(s.ResourceIDs, ",")v, err := model.GetEntityByID(r.ctx, r.ds, firstId)if err != nil {return "", errdiff --git a/log/journal.go b/log/journal.goindex f1c17d2e7..dd7cf5400 100644--- a/log/journal.go+++ b/log/journal.go@@ -36,6 +36,6 @@ func (f *journalFormatter) Format(entry *logrus.Entry) ([]byte, error) {if !ok {priority = 6 // default to info for unknown levels}- prefix := []byte(fmt.Sprintf("<%d>", priority))+ prefix := fmt.Appendf(nil, "<%d>", priority)return append(prefix, formatted...), nil}diff --git a/model/tag_mappings.go b/model/tag_mappings.goindex af76de741..dd19a157b 100644--- a/model/tag_mappings.go+++ b/model/tag_mappings.go@@ -47,8 +47,8 @@ func (c TagConf) SplitTagValue(values []string) []string {tag = c.SplitRx.ReplaceAllString(tag, consts.Zwsp)// Split by the zero-width space and trim each substring.- parts := strings.Split(tag, consts.Zwsp)- for _, part := range parts {+ parts := strings.SplitSeq(tag, consts.Zwsp)+ for part := range parts {result = append(result, strings.TrimSpace(part))}}diff --git a/persistence/sql_search_fts.go b/persistence/sql_search_fts.goindex e9b961d91..b90dc937b 100644--- a/persistence/sql_search_fts.go+++ b/persistence/sql_search_fts.go@@ -66,7 +66,7 @@ func normalizeForFTS(values ...string) string {result = append(result, variant)}for _, v := range values {- for _, word := range strings.Fields(v) {+ for word := range strings.FieldsSeq(v) {transliterated := sanitize.Accents(word)// Concatenated ASCII form: R.E.M. → REM, AC/DC → ACDC, St-Étienne → StEtienne.add(word, fts5PunctStrip.ReplaceAllString(transliterated, ""))@@ -279,9 +279,9 @@ type ftsSearch struct {}// ToSql returns a single-query fallback for the REST filter path (no two-phase split).-func (s *ftsSearch) ToSql() (string, []interface{}, error) {+func (s *ftsSearch) ToSql() (string, []any, error) {sql := s.tableName + ".rowid IN (SELECT rowid FROM " + s.ftsTable + " WHERE " + s.ftsTable + " MATCH ?)"- return sql, []interface{}{s.matchExpr}, nil+ return sql, []any{s.matchExpr}, nil}// execute runs a two-phase FTS5 search:@@ -373,8 +373,8 @@ func ftsQueryDegraded(original, ftsQuery string) bool {// Check if all effective FTS tokens are very short (≤2 chars).// Short tokens with prefix matching are too broad when special chars were stripped.// For quoted phrases, extract the content and check the tokens inside.- tokens := strings.Fields(ftsQuery)- for _, t := range tokens {+ tokens := strings.FieldsSeq(ftsQuery)+ for t := range tokens {t = strings.TrimSuffix(t, "*")// Skip internal phrase placeholdersif strings.HasPrefix(t, "\x00") {@@ -390,7 +390,7 @@ func ftsQueryDegraded(original, ftsQuery string) bool {// Extract content between quotesinner := strings.Trim(t, `"`)innerAlpha := fts5PunctStrip.ReplaceAllString(inner, " ")- for _, it := range strings.Fields(innerAlpha) {+ for it := range strings.FieldsSeq(innerAlpha) {if len(it) > 2 {return false}diff --git a/persistence/sql_search_like.go b/persistence/sql_search_like.goindex 769a911d5..972545ac5 100644--- a/persistence/sql_search_like.go+++ b/persistence/sql_search_like.go@@ -16,7 +16,7 @@ type likeSearch struct {filter Sqlizer}-func (s *likeSearch) ToSql() (string, []interface{}, error) {+func (s *likeSearch) ToSql() (string, []any, error) {return s.filter.ToSql()}diff --git a/plugins/host_taskqueue.go b/plugins/host_taskqueue.goindex eff73c822..a5db3344f 100644--- a/plugins/host_taskqueue.go+++ b/plugins/host_taskqueue.go@@ -6,6 +6,7 @@ import ("errors""fmt""io"+ "maps""os""path/filepath""sync"@@ -540,9 +541,7 @@ func (s *taskQueueServiceImpl) cleanupLoop() {func (s *taskQueueServiceImpl) runCleanup() {s.mu.Lock()queues := make(map[string]*queueState, len(s.queues))- for k, v := range s.queues {- queues[k] = v- }+ maps.Copy(queues, s.queues)s.mu.Unlock()now := time.Now().UnixMilli()diff --git a/plugins/host_taskqueue_test.go b/plugins/host_taskqueue_test.goindex 8a58f1eb4..faff79c8e 100644--- a/plugins/host_taskqueue_test.go+++ b/plugins/host_taskqueue_test.go@@ -367,8 +367,8 @@ var _ = Describe("TaskQueueService", func() {// Enqueue several more tasks — they stay pending since the worker is busyvar pendingIDs []string- for i := 0; i < 3; i++ {- taskID, err := service.Enqueue(ctx, "clear-test", []byte(fmt.Sprintf("task-%d", i)))+ for i := range 3 {+ taskID, err := service.Enqueue(ctx, "clear-test", fmt.Appendf(nil, "task-%d", i))Expect(err).ToNot(HaveOccurred())pendingIDs = append(pendingIDs, taskID)}@@ -674,8 +674,8 @@ var _ = Describe("TaskQueueService", func() {Expect(err).ToNot(HaveOccurred())// Enqueue 5 tasks- for i := 0; i < 5; i++ {- _, err := service.Enqueue(ctx, "delay-concurrent", []byte(fmt.Sprintf("task-%d", i)))+ for i := range 5 {+ _, err := service.Enqueue(ctx, "delay-concurrent", fmt.Appendf(nil, "task-%d", i))Expect(err).ToNot(HaveOccurred())}@@ -1112,7 +1112,7 @@ var _ = Describe("TaskQueueService Integration", Ordered, func() {// the second will be dequeued but block on the rate limiter (status=running),// the rest will stay pending.var taskIDs []string- for i := 0; i < 5; i++ {+ for range 5 {output, err := callTestTaskQueue(ctx, testTaskQueueInput{Operation: "enqueue",QueueName: "test-cancel",@@ -1186,11 +1186,11 @@ var _ = Describe("TaskQueueService Integration", Ordered, func() {Expect(err).ToNot(HaveOccurred())// Enqueue several tasks- for i := 0; i < 4; i++ {+ for i := range 4 {_, err := callTestTaskQueue(ctx, testTaskQueueInput{Operation: "enqueue",QueueName: "test-clear",- Payload: []byte(fmt.Sprintf("task-%d", i)),+ Payload: fmt.Appendf(nil, "task-%d", i),})Expect(err).ToNot(HaveOccurred())}diff --git a/scheduler/crontab_schedule_test.go b/scheduler/crontab_schedule_test.goindex b1e26f1de..b616f0884 100644--- a/scheduler/crontab_schedule_test.go+++ b/scheduler/crontab_schedule_test.go@@ -185,7 +185,7 @@ var _ = Describe("ParseCrontab", func() {// findSetBit returns the lowest bit position set in v, ignoring the starBit (bit 63).func findSetBit(v uint64) int {v &^= 1 << 63 // clear starBit- for i := 0; i < 63; i++ {+ for i := range 63 {if v&(1<<uint(i)) != 0 {return i}diff --git a/server/subsonic/api_test.go b/server/subsonic/api_test.goindex a1b66925a..b565109a5 100644--- a/server/subsonic/api_test.go+++ b/server/subsonic/api_test.go@@ -1,6 +1,7 @@package subsonicimport (+ "context""encoding/json""encoding/xml""fmt"@@ -13,7 +14,6 @@ import ("github.com/navidrome/navidrome/server/subsonic/responses". "github.com/onsi/ginkgo/v2". "github.com/onsi/gomega"- "golang.org/x/net/context")var _ = Describe("sendResponse", func() {diff --git a/server/throttle_backlog.go b/server/throttle_backlog.goindex c3672fd1e..0d31d289e 100644--- a/server/throttle_backlog.go+++ b/server/throttle_backlog.go@@ -4,6 +4,7 @@ import ("bytes""context""errors"+ "maps""net/http""sync""time"@@ -76,9 +77,7 @@ func (t *requestThrottle) handler(next http.Handler) http.Handler {next.ServeHTTP(buf, r)}()- for k, v := range buf.header {- w.Header()[k] = v- }+ maps.Copy(w.Header(), buf.header)if buf.code > 0 {w.WriteHeader(buf.code)}diff --git a/utils/cache/benchmark_test.go b/utils/cache/benchmark_test.goindex e3fc08eda..9ab07cf18 100644--- a/utils/cache/benchmark_test.go+++ b/utils/cache/benchmark_test.go@@ -116,7 +116,7 @@ func BenchmarkConcurrentCacheRead(b *testing.B) {for i := 0; i < b.N; i++ {var wg sync.WaitGroupwg.Add(n)- for g := 0; g < n; g++ {+ for range n {go func() {defer wg.Done()s, err := fc.Get(context.Background(), item)@@ -152,7 +152,7 @@ func BenchmarkConcurrentCacheMiss(b *testing.B) {wg.Add(n)// All goroutines request the SAME key (not yet cached)item := &benchItem{key: fmt.Sprintf("miss-%d", i)}- for g := 0; g < n; g++ {+ for range n {go func() {defer wg.Done()s, err := fc.Get(context.Background(), item)