Run modernize. Deprecate Go 1.22 by klauspost · Pull Request #1095 · klauspost/compress (original) (raw)
📝 Walkthrough
Walkthrough
Bump CI and module Go versions; widespread syntactic modernizations replacing interface{} with any, consolidate boundary clamps to min/max helpers, and convert many counted for loops to range-over-integer forms across core packages and tests. No exported API signatures intended to change.
Changes
| Cohort / File(s) | Summary |
|---|---|
| CI & module toolchains.github/workflows/go.yml, .github/workflows/release.yml, go.mod, huff0/_generate/go.mod, s2/cmd/_s2sx/go.mod, zstd/_generate/go.mod, s2/_generate/go.mod | Bump GitHub Actions Go matrix to include 1.25.x and update pinned workflow tool versions; update module go and toolchain directives and selected indirect tooling versions. |
| any / sync.Pool New updatesflate/stateless.go, dict/builder.go, gzhttp/compress.go, gzhttp/writer/gzkp/gzkp.go, gzhttp/writer/gzstd/stdlib.go, internal/lz4ref/block.go, s2/writer.go, zstd/blockdec.go, zstd/zip.go, internal/*, s2/* | Replace interface{} return types or variadic params with any (including sync.Pool.New literals and internal debug helpers). Purely syntactic modernization. |
| **Clamp consolidations (min/max)**dict/builder.go, flate/deflate.go, flate/dict_decoder.go, flate/level5.go, s2/encode_all.go, s2/encode_best.go, s2/encode_better.go, zstd/decoder.go, zstd/framedec.go, zstd/seqdec.go, zstd/seqdec_amd64.go, zstd/enc_base.go, zstd/enc_best.go, zstd/enc_better.go, s2/encode_* | Replace multi-step boundary clamps and conditional clamps with single min/max helper expressions to centralize bounds logic; semantics intended to be preserved. |
| Range-over-integer loop style changesflate/deflate.go, flate/huffman_bit_writer.go, flate/huffman_code.go, flate/inflate.go, fse/bitwriter.go, fse/compress.go, huff0/*, internal/snapref/decode.go, s2/reader.go, zstd/blockdec.go, zstd/snappy.go, zstd/fse_encoder.go, snappy/*, many test files (e.g., flate/*_test.go, gzhttp/*_test.go, s2/*_test.go, zstd/*_test.go, zip/*_test.go, gzip/*_test.go) | Convert many counted for i := 0; i < N; i++ loops to range-over-integer forms (e.g., for range N). Mostly stylistic and preserve iteration counts, but some changes affect loop-variable capture or introduce invalid range uses that require attention. |
| zstd encoder internals & dict updateszstd/enc_fast.go, zstd/enc_dfast.go, zstd/enc_better.go, zstd/dict.go | Consolidate clamp patterns to max(...), refactor table updates (including marking shards dirty), simplify debug helpers, and adjust internal bookkeeping in encoder/dictionary paths. Internal logic changes beyond purely syntactic edits. |
| Bit-writer flush adjustmentsfse/bitwriter.go, huff0/bitwriter.go, zstd/bitwriter.go | Convert byte-flush loops to range-based forms; zstd/bitwriter also clears bitContainer after flushing. |
| gzhttp & related pools/testsgzhttp/compress.go, gzhttp/asserts_test.go, gzhttp/compress_test.go, gzhttp/writer/gzkp/gzkp.go, gzhttp/writer/gzstd/stdlib.go | Simplify buffer sizing with max, use strings.CutPrefix for parsing q= values, update pools to any, modernize test helper signatures to any, minor assertion message tweak, and some subtest capture adjustments. |
| Tests: numeric-loop conversions & capture changesflate/*_test.go, gzip/*_test.go, huff0/*_test.go, s2/*_test.go, snappy/*_test.go, zip/*_test.go, zstd/*_test.go, zlib/writer_test.go, gzhttp/*_test.go, internal/xxhash/xxhash_test.go | Numerous tests converted counted loops to range forms; several per-iteration rebinding lines removed (may affect subtest closure capture), and a few tests use fmt.Appendf for direct byte construction. Review tests for capture-related regressions and compile correctness. |
| Misc small refactors & safety cleanupsflate/dict_decoder.go, flate/huffman_bit_writer.go, flate/level5.go, flate/stateless.go, zstd/decoder_test.go, zip/*, gzip/* | Small refactors: clamp expressions simplified, loop-form changes, minor message edits, and a few places where range-over-int usage may be invalid—check compile correctness. |
Estimated code review effort
🎯 4 (Complex) | ⏱️ ~60 minutes
Possibly related PRs
- flate: Cleanup & reduce casts #1050 — Related changes touching flate matchlen/boundary logic; overlaps with boundary-clamp edits in flate/level5.go.
- Deprecate Go 1.21 and add 1.24 #1055 — Related CI changes; also modifies Go version bumps in workflows.
- ci: Upgrade Go & other #1008 — Related CI and go.mod toolchain/version updates across the repo.
Tip
🔌 Remote MCP (Model Context Protocol) integration is now available!
Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.
✨ Finishing Touches
- 📝 Generate Docstrings 🧪 Generate unit tests
- Create PR with unit tests
- Post copyable unit tests in a comment
- Commit unit tests in branch
modernize-go
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share
Chat
There are 3 ways to chat with CodeRabbit:
- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
I pushed a fix in commit <commit_id>, please review it.Open a follow-up GitHub issue for this discussion.
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. - PR comments: Tag
@coderabbitaiin a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
Support
Need help? Create a ticket on our support page for assistance with any issues or questions.
CodeRabbit Commands (Invoked using PR/Issue comments)
Type @coderabbitai help to get the list of available commands.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere in the PR title to generate the title automatically.
CodeRabbit Configuration File (.coderabbit.yaml)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yamlfile to the root of your repository. - Please see the configuration documentation for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation:
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
Status, Documentation and Community
- Visit our Status Page to check the current availability of CodeRabbit.
- Visit our Documentation for detailed information on how to use CodeRabbit.
- Join our Discord Community to get help, request features, and share feedback.
- Follow us on X/Twitter for updates and announcements.