refactor: run Go modernize (#5002)

This commit is contained in:
Maximilian
2026-02-08 08:57:30 -06:00
committed by GitHub
parent 408aa78ed5
commit a704e86ac1
102 changed files with 322 additions and 352 deletions
+1 -1
View File
@@ -319,7 +319,7 @@ func sendResponse(w http.ResponseWriter, r *http.Request, payload *responses.Sub
callback, _ := p.String("callback")
wrapper := &responses.JsonWrapper{Subsonic: *payload}
response, err = json.Marshal(wrapper)
response = []byte(fmt.Sprintf("%s(%s)", callback, response))
response = fmt.Appendf(nil, "%s(%s)", callback, response)
default:
w.Header().Set("Content-Type", "application/xml")
response, err = xml.Marshal(payload)
+4 -4
View File
@@ -34,10 +34,10 @@ func newResponse() *responses.Subsonic {
type subError struct {
code int32
messages []interface{}
messages []any
}
func newError(code int32, message ...interface{}) error {
func newError(code int32, message ...any) error {
return subError{
code: code,
messages: message,
@@ -176,8 +176,8 @@ func isClientInList(clientList, client string) bool {
if clientList == "" || client == "" {
return false
}
clients := strings.Split(clientList, ",")
for _, c := range clients {
clients := strings.SplitSeq(clientList, ",")
for c := range clients {
if strings.TrimSpace(c) == client {
return true
}
+4 -3
View File
@@ -5,6 +5,7 @@ import (
"errors"
"io"
"net/http"
"strings"
"time"
"github.com/navidrome/navidrome/conf"
@@ -120,12 +121,12 @@ func (api *Router) GetLyrics(r *http.Request) (*responses.Subsonic, error) {
lyricsResponse.Artist = artist
lyricsResponse.Title = title
lyricsText := ""
var lyricsText strings.Builder
for _, line := range structuredLyrics[0].Line {
lyricsText += line.Value + "\n"
lyricsText.WriteString(line.Value + "\n")
}
lyricsResponse.Value = lyricsText
lyricsResponse.Value = lyricsText.String()
return response, nil
}
+1 -1
View File
@@ -459,7 +459,7 @@ type PlayQueueByIndex struct {
}
type Bookmark struct {
Entry Child `xml:"entry,omitempty" json:"entry,omitempty"`
Entry Child `xml:"entry,omitempty" json:"entry"`
Position int64 `xml:"position,attr,omitempty" json:"position,omitempty"`
Username string `xml:"username,attr" json:"username"`
Comment string `xml:"comment,attr" json:"comment"`
@@ -26,17 +26,17 @@ type snapshotMatcher struct {
c *cupaloy.Config
}
func (matcher snapshotMatcher) Match(actual interface{}) (success bool, err error) {
func (matcher snapshotMatcher) Match(actual any) (success bool, err error) {
actualJson := strings.TrimSpace(string(actual.([]byte)))
err = matcher.c.SnapshotWithName(ginkgo.CurrentSpecReport().FullText(), actualJson)
success = err == nil
return
}
func (matcher snapshotMatcher) FailureMessage(_ interface{}) (message string) {
func (matcher snapshotMatcher) FailureMessage(_ any) (message string) {
return "Expected to match saved snapshot\n"
}
func (matcher snapshotMatcher) NegatedFailureMessage(_ interface{}) (message string) {
func (matcher snapshotMatcher) NegatedFailureMessage(_ any) (message string) {
return "Expected to not match saved snapshot\n"
}
+1 -1
View File
@@ -30,7 +30,7 @@ var _ = Describe("Search", func() {
})
Context("musicFolderId parameter", func() {
assertQueryOptions := func(filter squirrel.Sqlizer, expectedQuery string, expectedArgs ...interface{}) {
assertQueryOptions := func(filter squirrel.Sqlizer, expectedQuery string, expectedArgs ...any) {
GinkgoHelper()
query, args, err := filter.ToSql()
Expect(err).ToNot(HaveOccurred())