From 1bf4a5b0c1e209770b060c8b4a08910afb72078f Mon Sep 17 00:00:00 2001 From: sentriz Date: Sat, 6 Sep 2025 23:38:04 +0100 Subject: [PATCH] chore(deps)!: bump to go1.25 fixes #594 Release-As: 0.18.0 --- .github/workflows/nightly-release.yaml | 2 +- .github/workflows/release.yaml | 2 +- .github/workflows/test.yaml | 2 +- Dockerfile | 2 +- db/db.go | 11 ++++------- go.mod | 12 +++++------- go.sum | 20 ++++++++------------ mockfs/mockfs.go | 8 ++++---- scanner/scanner_benchmark_test.go | 9 ++++----- scanner/scanner_fuzz_test.go | 2 +- scanner/scanner_test.go | 6 +++--- server/ctrladmin/ctrl.go | 2 +- server/ctrlsubsonic/ctrl_test.go | 1 - server/ctrlsubsonic/handlers_raw.go | 6 ++---- server/ctrlsubsonic/params/params.go | 7 +++---- server/ctrlsubsonic/spec/spec.go | 6 +++--- server/ctrlsubsonic/specid/ids_test.go | 1 - transcode/transcode_test.go | 9 +++------ 18 files changed, 45 insertions(+), 63 deletions(-) diff --git a/.github/workflows/nightly-release.yaml b/.github/workflows/nightly-release.yaml index 87e1dd0..68e5991 100644 --- a/.github/workflows/nightly-release.yaml +++ b/.github/workflows/nightly-release.yaml @@ -36,7 +36,7 @@ jobs: uses: golangci/golangci-lint-action@v8 with: install-mode: goinstall - version: v2.3.0 + version: v2.4.0 - name: Test run: go test ./... build-release: diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index f4a3c01..a697215 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -22,7 +22,7 @@ jobs: uses: golangci/golangci-lint-action@v8 with: install-mode: goinstall - version: v2.3.0 + version: v2.4.0 - name: Test run: go test ./... release-please: diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index c8c56a2..68fbb98 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -23,6 +23,6 @@ jobs: uses: golangci/golangci-lint-action@v8 with: install-mode: goinstall - version: v2.3.0 + version: v2.4.0 - name: Test run: go test ./... diff --git a/Dockerfile b/Dockerfile index e33d7ef..933af85 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,7 +7,7 @@ RUN apk update && \ abuild-keygen -a -n -i && \ REPODEST=/pkgs abuild -F -r -FROM golang:1.24-alpine3.22 AS builder +FROM golang:1.25-alpine3.22 AS builder RUN apk add -U --no-cache \ build-base \ ca-certificates \ diff --git a/db/db.go b/db/db.go index 7e9ad09..1261b93 100644 --- a/db/db.go +++ b/db/db.go @@ -67,7 +67,7 @@ func (db *DB) InsertBulkLeftMany(table string, head []string, left int, col []in return nil } var rows []string - var values []interface{} + var values []any for _, c := range col { rows = append(rows, "(?, ?)") values = append(values, left, c) @@ -138,10 +138,7 @@ func (db *DB) TransactionChunked(data []int64, cb func(*DB, []int64) error) erro const size = 999 return db.Transaction(func(tx *DB) error { for i := 0; i < len(data); i += size { - end := i + size - if end > len(data) { - end = len(data) - } + end := min(i+size, len(data)) if err := cb(tx, data[i:end]); err != nil { return err } @@ -643,8 +640,8 @@ func Dump(ctx context.Context, db *gorm.DB, to string) error { } defer connDest.Close() - err = connDest.Raw(func(connDest interface{}) error { - return connSrc.Raw(func(connSrc interface{}) error { + err = connDest.Raw(func(connDest any) error { + return connSrc.Raw(func(connSrc any) error { connDestq := connDest.(*sqlite3.SQLiteConn) connSrcq := connSrc.(*sqlite3.SQLiteConn) bk, err := connDestq.Backup("main", connSrcq, "main") diff --git a/go.mod b/go.mod index a921471..9a50484 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module go.senan.xyz/gonic -go 1.24 +go 1.25 require ( github.com/Masterminds/sprig v2.22.0+incompatible @@ -27,9 +27,9 @@ require ( github.com/rainycape/unidecode v0.0.0-20150907023854-cb7f23ec59be github.com/sentriz/audiotags v0.0.0-20240918190302-048d6470aae6 github.com/sentriz/gormstore v0.0.0-20220105134332-64e31f7f6981 - github.com/stretchr/testify v1.10.0 + github.com/stretchr/testify v1.11.1 go.senan.xyz/flagconf v0.1.9 - go.senan.xyz/wrtag v0.16.0 + go.senan.xyz/wrtag v0.17.1 golang.org/x/net v0.43.0 golang.org/x/sync v0.16.0 gopkg.in/gormigrate.v1 v1.6.0 @@ -41,18 +41,16 @@ require ( github.com/PuerkitoBio/goquery v1.10.3 // indirect github.com/aymerick/douceur v0.2.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect - github.com/go-openapi/jsonpointer v0.21.2 // indirect - github.com/go-openapi/swag v0.23.1 // indirect + github.com/go-openapi/jsonpointer v0.22.0 // indirect + github.com/go-openapi/swag/jsonname v0.24.0 // indirect github.com/gorilla/context v1.1.2 // indirect github.com/gorilla/css v1.0.1 // indirect github.com/huandu/xstrings v1.5.0 // indirect github.com/imdario/mergo v0.3.16 // indirect github.com/jinzhu/inflection v1.0.0 // indirect github.com/jinzhu/now v1.1.2 // indirect - github.com/josharian/intern v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/lib/pq v1.3.0 // indirect - github.com/mailru/easyjson v0.9.0 // indirect github.com/mitchellh/copystructure v1.2.0 // indirect github.com/mitchellh/reflectwalk v1.0.2 // indirect github.com/mmcdole/goxpp v1.1.1 // indirect diff --git a/go.sum b/go.sum index e0fbc3a..1b93271 100644 --- a/go.sum +++ b/go.sum @@ -35,10 +35,10 @@ github.com/fatih/structs v1.1.0 h1:Q7juDM0QtcnhCpeyLGQKyg4TOIghuNXrkL32pHAUMxo= github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M= github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k= github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0= -github.com/go-openapi/jsonpointer v0.21.2 h1:AqQaNADVwq/VnkCmQg6ogE+M3FOsKTytwges0JdwVuA= -github.com/go-openapi/jsonpointer v0.21.2/go.mod h1:50I1STOfbY1ycR8jGz8DaMeLCdXiI6aDteEdRNNzpdk= -github.com/go-openapi/swag v0.23.1 h1:lpsStH0n2ittzTnbaSloVZLuB5+fvSY/+hnagBjSNZU= -github.com/go-openapi/swag v0.23.1/go.mod h1:STZs8TbRvEQQKUA+JZNAm3EWlgaOBGpyFDqQnDHMef0= +github.com/go-openapi/jsonpointer v0.22.0 h1:TmMhghgNef9YXxTu1tOopo+0BGEytxA+okbry0HjZsM= +github.com/go-openapi/jsonpointer v0.22.0/go.mod h1:xt3jV88UtExdIkkL7NloURjRQjbeUgcxFblMjq2iaiU= +github.com/go-openapi/swag/jsonname v0.24.0 h1:2wKS9bgRV/xB8c62Qg16w4AUiIrqqiniJFtZGi3dg5k= +github.com/go-openapi/swag/jsonname v0.24.0/go.mod h1:GXqrPzGJe611P7LG4QB9JKPtUZ7flE4DOVechNaDd7Q= github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs= github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= @@ -84,8 +84,6 @@ github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc= github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= github.com/josephburnett/jd v1.9.2 h1:ECJRRFXCCqbtidkAHckHGSZm/JIaAxS1gygHLF8MI5Y= github.com/josephburnett/jd v1.9.2/go.mod h1:bImDr8QXpxMb3SD+w1cDRHp97xP6UwI88xUAuxwDQfM= -github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= -github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= @@ -96,8 +94,6 @@ github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lib/pq v1.3.0 h1:/qkRGz8zljWiDcFvgpwUpwIAPu3r07TDvs3Rws+o/pU= github.com/lib/pq v1.3.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= -github.com/mailru/easyjson v0.9.0 h1:PrnmzHw7262yW8sTBwxi1PdJA3Iw/EKBa8psRf7d9a4= -github.com/mailru/easyjson v0.9.0/go.mod h1:1+xMtQp2MRNVL/V1bOzuP3aP8VNwRW55fQUto+XFtTU= github.com/mattn/go-sqlite3 v1.10.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= github.com/mattn/go-sqlite3 v1.14.0/go.mod h1:JIl7NbARA7phWnGvh0LKTyg7S9BA+6gx71ShQilpsus= github.com/mattn/go-sqlite3 v1.14.32 h1:JD12Ag3oLy1zQA+BNn74xRgaBbdhbNIDYvQUEuuErjs= @@ -135,13 +131,13 @@ github.com/sentriz/gormstore v0.0.0-20220105134332-64e31f7f6981 h1:sLILANWN76ja6 github.com/sentriz/gormstore v0.0.0-20220105134332-64e31f7f6981/go.mod h1:Rx8XB1ck+so+41uu9VY1gMKs1CPQ2NTq0pzf+OCCQHo= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= -github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= +github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= go.senan.xyz/flagconf v0.1.9 h1:LBDmqiVFgijfqFXDzH97gPn0qDbg1Dq6/vxsxS/TzC4= go.senan.xyz/flagconf v0.1.9/go.mod h1:NqOFfSwJvNWXOTUabcRZ8mPK9+sJmhStJhqtEt74wNQ= -go.senan.xyz/wrtag v0.16.0 h1:Txcl4OXwfLe5PO7agfRGaRD00GLji5wn9qwLFD/aR1E= -go.senan.xyz/wrtag v0.16.0/go.mod h1:XAbiIGbf0DP22RcQBW1n1KeeUTGQU9B6k5A6CGw2j4A= +go.senan.xyz/wrtag v0.17.1 h1:QC40z0rRAZ8zjIwwIrFIhldviP9cW0Jpe9EDh5Bt2J8= +go.senan.xyz/wrtag v0.17.1/go.mod h1:rrC+QaFcZACW/hcsZpQj6kTh69rjhxIoePk3MZG3/rA= golang.org/x/crypto v0.0.0-20181112202954-3d3f9f413869/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= diff --git a/mockfs/mockfs.go b/mockfs/mockfs.go index 36dd1b6..5d658ae 100644 --- a/mockfs/mockfs.go +++ b/mockfs/mockfs.go @@ -116,12 +116,12 @@ func (m *MockFS) AddItemsWithCovers() { m.addItems("", "", tr func (m *MockFS) AddItemsPrefixWithCovers(prefix string) { m.addItems(prefix, "", true) } func (m *MockFS) addItems(prefix string, onlyGlob string, covers bool) { - p := func(format string, a ...interface{}) string { + p := func(format string, a ...any) string { return filepath.Join(prefix, fmt.Sprintf(format, a...)) } - for ar := 0; ar < 3; ar++ { - for al := 0; al < 3; al++ { - for tr := 0; tr < 3; tr++ { + for ar := range 3 { + for al := range 3 { + for tr := range 3 { path := p("artist-%d/album-%d/track-%d.flac", ar, al, tr) if !match(onlyGlob, path) { continue diff --git a/scanner/scanner_benchmark_test.go b/scanner/scanner_benchmark_test.go index 22149fe..f68545a 100644 --- a/scanner/scanner_benchmark_test.go +++ b/scanner/scanner_benchmark_test.go @@ -9,21 +9,20 @@ import ( func BenchmarkScanIncremental(b *testing.B) { m := mockfs.New(b) - for i := 0; i < 5; i++ { + for i := range 5 { m.AddItemsPrefix(fmt.Sprintf("t-%d", i)) } m.ScanAndClean() - b.ResetTimer() - for i := 0; i < b.N; i++ { + for b.Loop() { m.ScanAndClean() } } func BenchmarkScanFull(b *testing.B) { - for i := 0; i < b.N; i++ { + for b.Loop() { m := mockfs.New(b) - for i := 0; i < 5; i++ { + for i := range 5 { m.AddItemsPrefix(fmt.Sprintf("t-%d", i)) } b.StartTimer() diff --git a/scanner/scanner_fuzz_test.go b/scanner/scanner_fuzz_test.go index b4fc28b..e88352e 100644 --- a/scanner/scanner_fuzz_test.go +++ b/scanner/scanner_fuzz_test.go @@ -43,7 +43,7 @@ func FuzzScanner(f *testing.F) { }) } -func fuzzStruct(taken int, data []byte, seed int64, dest interface{}) { +func fuzzStruct(taken int, data []byte, seed int64, dest any) { if len(data) == 0 { return } diff --git a/scanner/scanner_test.go b/scanner/scanner_test.go index c49b6f8..50e8640 100644 --- a/scanner/scanner_test.go +++ b/scanner/scanner_test.go @@ -363,7 +363,7 @@ func TestNewAlbumForExistingArtist(t *testing.T) { assert.NoError(t, m.DB().Where("name=?", "artist-2").Find(&artist).Error) // find orig artist assert.Greater(t, artist.ID, 0) - for tr := 0; tr < 3; tr++ { + for tr := range 3 { m.AddTrack(fmt.Sprintf("artist-2/new-album/track-%d.mp3", tr)) m.SetTags(fmt.Sprintf("artist-2/new-album/track-%d.mp3", tr), func(tags *mockfs.TagInfo) { tags.RawArtist = "artist-2" @@ -552,7 +552,7 @@ func TestCompilationAlbumWithoutAlbumArtist(t *testing.T) { const toAdd = 5 // add tracks to one folder with random artists and no album artist tag - for i := 0; i < toAdd; i++ { + for i := range toAdd { p := fmt.Sprintf("%s/%s/track-%d.flac", pathArtist, pathAlbum, i) m.AddTrack(p) m.SetTags(p, func(tags *mockfs.TagInfo) { @@ -605,7 +605,7 @@ func TestAlbumAndArtistSameNameWeirdness(t *testing.T) { const name = "same" - add := func(path string, a ...interface{}) { + add := func(path string, a ...any) { m.AddTrack(fmt.Sprintf(path, a...)) m.SetTags(fmt.Sprintf(path, a...), func(tags *mockfs.TagInfo) {}) } diff --git a/server/ctrladmin/ctrl.go b/server/ctrladmin/ctrl.go index 063869f..3722f72 100644 --- a/server/ctrladmin/ctrl.go +++ b/server/ctrladmin/ctrl.go @@ -271,7 +271,7 @@ func respRaw(h http.HandlerFunc) http.Handler { type templateData struct { // common - Flashes []interface{} + Flashes []any User *db.User Version string diff --git a/server/ctrlsubsonic/ctrl_test.go b/server/ctrlsubsonic/ctrl_test.go index 227ddd5..603f91e 100644 --- a/server/ctrlsubsonic/ctrl_test.go +++ b/server/ctrlsubsonic/ctrl_test.go @@ -87,7 +87,6 @@ func makeHTTPMockWithAdmin(query url.Values) (*httptest.ResponseRecorder, *http. func runQueryCases(t *testing.T, h handlerSubsonic, cases []*queryCase) { t.Helper() for _, qc := range cases { - qc := qc t.Run(qc.expectPath, func(t *testing.T) { t.Helper() t.Parallel() diff --git a/server/ctrlsubsonic/handlers_raw.go b/server/ctrlsubsonic/handlers_raw.go index fd19fd8..73ee80b 100644 --- a/server/ctrlsubsonic/handlers_raw.go +++ b/server/ctrlsubsonic/handlers_raw.go @@ -155,11 +155,9 @@ func coverScaleAndSave(reader io.Reader, cachePath string, size int) error { if err != nil { return fmt.Errorf("resizing: %w", err) } - width := size - if width > src.Bounds().Dx() { + width := min(size, // don't upscale images - width = src.Bounds().Dx() - } + src.Bounds().Dx()) if err := imaging.Save(imaging.Resize(src, width, 0, imaging.Lanczos), cachePath); err != nil { return fmt.Errorf("caching %q: %w", cachePath, err) } diff --git a/server/ctrlsubsonic/params/params.go b/server/ctrlsubsonic/params/params.go index 022c4e2..53a5203 100644 --- a/server/ctrlsubsonic/params/params.go +++ b/server/ctrlsubsonic/params/params.go @@ -27,6 +27,7 @@ package params import ( "errors" + "maps" "net/http" "net/url" "strconv" @@ -44,9 +45,7 @@ func New(r *http.Request) Params { params := r.URL.Query() // also if there's any in the post body, use those too if err := r.ParseForm(); err == nil { - for k, v := range r.Form { - params[k] = v - } + maps.Copy(params, r.Form) } return Params(params) } @@ -389,7 +388,7 @@ func parseTime(in string) (time.Time, error) { return time.Unix(0, ns), nil } -func parse(values []string, i interface{}) error { +func parse(values []string, i any) error { if len(values) == 0 { return ErrNoValues } diff --git a/server/ctrlsubsonic/spec/spec.go b/server/ctrlsubsonic/spec/spec.go index 933dbdd..40c1f38 100644 --- a/server/ctrlsubsonic/spec/spec.go +++ b/server/ctrlsubsonic/spec/spec.go @@ -102,7 +102,7 @@ type Error struct { Message string `xml:"message,attr" json:"message"` } -func NewError(code int, message string, a ...interface{}) *Response { +func NewError(code int, message string, a ...any) *Response { r := NewResponse() r.Status = "failed" r.Error = &Error{ @@ -128,7 +128,7 @@ type GenreRef struct { // https://opensubsonic.netlify.app/docs/responses/albumid3/ type Album struct { ID *specid.ID `xml:"id,attr,omitempty" json:"id"` - Created time.Time `xml:"created,attr,omitempty" json:"created,omitempty"` + Created time.Time `xml:"created,attr,omitempty" json:"created"` // legacy or single tag mode ArtistID *specid.ID `xml:"artistId,attr,omitempty" json:"artistId,omitempty"` @@ -201,7 +201,7 @@ type TrackChild struct { Bitrate int `xml:"bitRate,attr,omitempty" json:"bitRate,omitempty"` ContentType string `xml:"contentType,attr,omitempty" json:"contentType,omitempty"` CoverID *specid.ID `xml:"coverArt,attr,omitempty" json:"coverArt,omitempty"` - CreatedAt time.Time `xml:"created,attr,omitempty" json:"created,omitempty"` + CreatedAt time.Time `xml:"created,attr,omitempty" json:"created"` Duration int `xml:"duration,attr,omitempty" json:"duration,omitempty"` Genre string `xml:"genre,attr,omitempty" json:"genre,omitempty"` Genres []*GenreRef `xml:"genres,omitempty" json:"genres,omitempty"` diff --git a/server/ctrlsubsonic/specid/ids_test.go b/server/ctrlsubsonic/specid/ids_test.go index d3e5303..2841b68 100644 --- a/server/ctrlsubsonic/specid/ids_test.go +++ b/server/ctrlsubsonic/specid/ids_test.go @@ -24,7 +24,6 @@ func TestParseID(t *testing.T) { } for _, tcase := range tcases { - tcase := tcase // pin t.Run(tcase.param, func(t *testing.T) { t.Parallel() diff --git a/transcode/transcode_test.go b/transcode/transcode_test.go index b28b7b6..aadfb3e 100644 --- a/transcode/transcode_test.go +++ b/transcode/transcode_test.go @@ -116,15 +116,12 @@ func TestCachingParallelism(t *testing.T) { cacheTranscoder := transcode.NewCachingTranscoder(transcoder, t.TempDir(), 1024) var wg sync.WaitGroup - for i := 0; i < 5; i++ { - wg.Add(1) - go func() { - defer wg.Done() - + for range 5 { + wg.Go(func() { var buf bytes.Buffer require.NoError(t, cacheTranscoder.Transcode(context.Background(), transcode.PCM16le, "testdata/5s.flac", &buf)) require.Equal(t, 5*bytesPerSec, buf.Len()) - }() + }) } wg.Wait()