From 461c6bf514c10d781b33a776dbbfd76f32c9acd9 Mon Sep 17 00:00:00 2001 From: Bryan Van Deusen Date: Wed, 20 May 2026 15:23:39 -0400 Subject: [PATCH] fix(go): collapse struct-literal copies to type conversions (S1016) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit staticcheck S1016 in the new golangci-lint v2 flagged four sites copying field-by-field between two types with identical struct shapes. Direct type conversion is the canonical form: - internal/library/scanrun.go: - LibraryStageTallies copy from Stats → LibraryStageTallies(lastStats) - MBIDBackfillStageTallies copy from BackfillMBIDsResult → MBIDBackfillStageTallies(lastRes) - internal/recommendation/home.go: - dbq.ListRediscoverAlbumsForUserRow copy from the Fallback row type → dbq.ListRediscoverAlbumsForUserRow(r) - Same pattern for the Artists rediscover pair. No behavior change; the underlying struct shapes are identical (staticcheck verified the conversion is valid). Net -18 +4 lines. Co-Authored-By: Claude Opus 4.7 (1M context) --- internal/library/scanrun.go | 11 ++--------- internal/recommendation/home.go | 11 ++--------- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/internal/library/scanrun.go b/internal/library/scanrun.go index a6c9de3d..5f42ecb5 100644 --- a/internal/library/scanrun.go +++ b/internal/library/scanrun.go @@ -100,11 +100,7 @@ func RunScan( var lastStats Stats libPub := newStagePublisher(ctx, 500, time.Second, func() []byte { - blob, _ := json.Marshal(LibraryStageTallies{ - Scanned: lastStats.Scanned, Added: lastStats.Added, - Updated: lastStats.Updated, Skipped: lastStats.Skipped, - Errored: lastStats.Errored, - }) + blob, _ := json.Marshal(LibraryStageTallies(lastStats)) return blob }, func(blob []byte) error { @@ -131,10 +127,7 @@ func RunScan( var lastRes BackfillMBIDsResult bfPub := newStagePublisher(ctx, 500, time.Second, func() []byte { - blob, _ := json.Marshal(MBIDBackfillStageTallies{ - Processed: lastRes.Processed, Healed: lastRes.Healed, - Skipped: lastRes.Skipped, Duplicates: lastRes.Duplicates, - }) + blob, _ := json.Marshal(MBIDBackfillStageTallies(lastRes)) return blob }, func(blob []byte) error { diff --git a/internal/recommendation/home.go b/internal/recommendation/home.go index 4ad696c4..28180427 100644 --- a/internal/recommendation/home.go +++ b/internal/recommendation/home.go @@ -145,10 +145,7 @@ func loadRediscoverAlbums(ctx context.Context, q *dbq.Queries, userID pgtype.UUI if _, dup := seen[r.Album.ID]; dup { continue } - primary = append(primary, dbq.ListRediscoverAlbumsForUserRow{ - Album: r.Album, - ArtistName: r.ArtistName, - }) + primary = append(primary, dbq.ListRediscoverAlbumsForUserRow(r)) if len(primary) >= HomeRediscoverLimit { break } @@ -181,11 +178,7 @@ func loadRediscoverArtists(ctx context.Context, q *dbq.Queries, userID pgtype.UU if _, dup := seen[r.Artist.ID]; dup { continue } - primary = append(primary, dbq.ListRediscoverArtistsForUserRow{ - Artist: r.Artist, - CoverAlbumID: r.CoverAlbumID, - AlbumCount: r.AlbumCount, - }) + primary = append(primary, dbq.ListRediscoverArtistsForUserRow(r)) if len(primary) >= HomeRediscoverLimit { break }