From e11011e97732bb5b160f15da467c6f1da66a8846 Mon Sep 17 00:00:00 2001 From: Bryan Van Deusen Date: Mon, 2 Nov 2026 13:56:22 -0500 Subject: [PATCH] fix: the backup package checks or explicitly drops every error the linter flags Closing a refused S3 response and a test file, and the fake bucket's writes, now say they ignore the error on purpose; handler parameters the tests don't use are named _. Co-Authored-By: Claude Opus 5.5 --- internal/backup/archive_test.go | 2 +- internal/backup/s3.go | 2 +- internal/backup/s3_test.go | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/internal/backup/archive_test.go b/internal/backup/archive_test.go index 08f39a74..6effe79d 100644 --- a/internal/backup/archive_test.go +++ b/internal/backup/archive_test.go @@ -154,7 +154,7 @@ func TestWriteFileLandsUnderTheDatedNameOnly(t *testing.T) { if err != nil { t.Fatal(err) } - defer f.Close() + defer func() { _ = f.Close() }() if _, _, err := Read(f); err != nil { t.Errorf("the written file doesn't read: %v", err) } diff --git a/internal/backup/s3.go b/internal/backup/s3.go index d69ad11b..60773795 100644 --- a/internal/backup/s3.go +++ b/internal/backup/s3.go @@ -86,7 +86,7 @@ func (b Bucket) do(req *http.Request, payloadSHA256 string) (*http.Response, err return nil, fmt.Errorf("%w: %s is unreachable: %v", ErrS3, req.URL.Host, err) } if resp.StatusCode/100 != 2 { - defer resp.Body.Close() + defer func() { _ = resp.Body.Close() }() return nil, refusal(resp) } return resp, nil diff --git a/internal/backup/s3_test.go b/internal/backup/s3_test.go index 543e225d..984a44ab 100644 --- a/internal/backup/s3_test.go +++ b/internal/backup/s3_test.go @@ -77,7 +77,7 @@ func testBucket(url string) Bucket { func TestPutSendsTheBodyToItsPathStyleKey(t *testing.T) { var gotPath, gotSHA, gotBody, gotAuth string var gotLen int64 - srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + srv := httptest.NewServer(http.HandlerFunc(func(_ http.ResponseWriter, r *http.Request) { gotPath, gotSHA, gotAuth, gotLen = r.URL.EscapedPath(), r.Header.Get("X-Amz-Content-Sha256"), r.Header.Get("Authorization"), r.ContentLength b, _ := io.ReadAll(r.Body) gotBody = string(b) @@ -108,13 +108,13 @@ func TestListFollowsContinuationTokens(t *testing.T) { return } if q.Get("continuation-token") == "" { - fmt.Fprint(w, `truenext + _, _ = fmt.Fprint(w, `truenext database/minstrel-20261101T030000Z.tar102026-11-01T03:00:05.000Z database/minstrel-20261102T030000Z.tar112026-11-02T03:00:05.000Z `) return } - fmt.Fprint(w, `false + _, _ = fmt.Fprint(w, `false database/minstrel-20261103T030000Z.tar122026-11-03T03:00:05.000Z `) })) @@ -131,9 +131,9 @@ func TestListFollowsContinuationTokens(t *testing.T) { } func TestARefusalSaysWhatIsWrong(t *testing.T) { - srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(http.StatusForbidden) - fmt.Fprint(w, `SignatureDoesNotMatchThe request signature we calculated does not match`) + _, _ = fmt.Fprint(w, `SignatureDoesNotMatchThe request signature we calculated does not match`) })) defer srv.Close()