Skip to content

Fix existing golangci-lint warnings in tests #99

Description

@corylanou

Problem

A full golangci-lint run currently reports five pre-existing warnings in test code. These were surfaced while reviewing #97 but are unrelated to that PR and should be fixed separately.

Unchecked file-close errors (errcheck)

  • checksum_test.go:83: defer f.Close() in testChecksumPages
  • checksum_test.go:116: defer f.Close() in legacyChecksumPages

Handle the close results explicitly using the repository test/helper conventions. Preserve any earlier operation error when propagating a close error from legacyChecksumPages.

Deprecated random reads (staticcheck SA1019)

  • ltx_test.go:698: rand.Read(data) in benchmarkChecksumPage
  • ltx_test.go:718: rand.Read(data) in benchmarkChecksumPageWithHasher
  • ltx_test.go:737: rand.Read(page) in BenchmarkXOR

math/rand.Read is deprecated. Replace it with an appropriate deterministic math/rand/v2 source for benchmark fixture data, or use crypto/rand if nondeterministic data is intentionally required. Keep random-data setup outside the timed benchmark sections.

Acceptance criteria

  • golangci-lint run exits successfully with no findings.
  • go test ./... passes.
  • go test -race ./... passes.
  • Existing benchmarks continue to operate on populated page data without adding random-data generation to their timed sections.
  • No production behavior changes are included.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions