Add support for transparent gzip handling#14
Conversation
There was a problem hiding this comment.
Pull request overview
This pull request adds transparent gzip handling for downloading AUR metadata, allowing the code to automatically detect and decompress gzip-compressed responses. The PR also updates Go from version 1.19 to 1.25, modernizes dependencies, updates GitHub Actions, restructures the golangci-lint configuration, and adds devcontainer support.
- Implements transparent gzip decompression in metadata downloads with magic number detection
- Updates dependencies including testing libraries (testify 1.8.1 → 1.11.1), gojq, and ojg
- Modernizes GitHub Actions workflow (checkout@v2 → v6, setup-go@v2 → v6, golangci-lint-action@v2 → v9)
Reviewed changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| metadata/cache.go | Adds newGzipResponseReader function with gzip magic number detection and two wrapper types (gzipReader, bufferedReader) to handle both compressed and uncompressed responses |
| metadata/integration_test.go | Adds integration test for real AUR metadata download with gzip decompression |
| rpc/req.go | Refactors empty string check from len(result.Error) > 0 to more idiomatic result.Error != "" |
| rpc/query.go | Removes custom min function and renames variable max to maxIdx for clarity (relies on builtin min from Go 1.21+) |
| go.mod | Updates Go version to 1.25 and upgrades dependencies |
| go.sum | Updates checksums for new dependency versions |
| .golangci.yml | Restructures configuration to version 2 format with new settings organization |
| .github/workflows/go.yml | Updates GitHub Actions versions and Go version, reduces test matrix to ubuntu-latest only |
| .devcontainer/devcontainer.json | Adds VS Code devcontainer configuration |
| .devcontainer/Dockerfile | Adds devcontainer Dockerfile based on jguer/yay-builder image |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| func (z *gzipReader) Close() error { | ||
| z.Reader.Close() |
There was a problem hiding this comment.
The Close method should handle errors from both closers. Currently, if Reader.Close() returns an error, it's ignored and only body.Close() error is returned. Consider using a multierror approach or at least log the first error.
|
|
||
| func newGzipResponseReader(body io.ReadCloser) (io.ReadCloser, error) { | ||
| br := bufio.NewReader(body) | ||
|
|
||
| // gzip magic number: 0x1f, 0x8b | ||
| if head, err := br.Peek(2); err == nil && len(head) == 2 && head[0] == 0x1f && head[1] == 0x8b { | ||
| gz, err := gzip.NewReader(br) | ||
| if err != nil { | ||
| body.Close() | ||
| return nil, fmt.Errorf("failed to create gzip reader: %w", err) | ||
| } | ||
| return &gzipReader{Reader: gz, body: body}, nil | ||
| } | ||
|
|
||
| return &bufferedReader{Reader: br, body: body}, nil |
There was a problem hiding this comment.
The new gzip handling functionality lacks unit test coverage. Consider adding tests for both gzip-compressed and uncompressed responses to verify the transparent decompression works correctly, and to test error cases such as invalid gzip data.
|
|
||
| version: "2" | ||
| run: | ||
| go: "1.18" |
There was a problem hiding this comment.
The Go version specified here (1.18) is inconsistent with the go.mod file which specifies 1.25. These should be aligned to ensure consistent linting behavior.
| go: "1.18" | |
| go: "1.25" |
No description provided.