Conversation
There was a problem hiding this comment.
Pull Request Overview
This pull request introduces a comprehensive self-update feature for the decoder CLI, allowing users to check for and apply updates directly from the command line. It also improves build metadata handling by injecting version information at build time via GoReleaser.
- Adds a new
updatesubcommand with support for stable releases and release candidates - Implements non-blocking update notifications at application startup
- Enhances build configuration to inject version metadata and handle releases properly
Reviewed Changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
internal/selfupdate/selfupdate.go |
Core self-update logic with GitHub API integration, archive handling, and binary replacement |
internal/selfupdate/selfupdate_test.go |
Comprehensive test suite for update functionality including mocking and edge cases |
internal/selfupdate/selfupdate_more_test.go |
Additional tests for helper functions and utility methods |
pkg/decoder/decoder_test.go |
Test coverage for decoder package interfaces and feature checking |
pkg/common/helpers_more_test.go |
Test suite for common helper functions including payload validation and encoding |
cmd/update.go |
Update subcommand implementation with timeout handling and user feedback |
cmd/version.go |
Version metadata variables for build-time injection |
cmd/root.go |
Integration of update checks and version display in root command |
.goreleaser.yaml |
Build configuration updates for metadata injection and release handling |
go.mod |
Addition of golang.org/x/mod dependency |
Comments suppressed due to low confidence (2)
internal/selfupdate/selfupdate_test.go:1
- The defer statement should handle the error from Close() to avoid potential issues in tests. Consider using
defer func() { _ = rc.Close() }()for consistency with the rest of the codebase.
package selfupdate
internal/selfupdate/selfupdate_test.go:1
- Similar to the previous comment, the defer should handle the Close() error. Consider using
defer func() { _ = out.Close() }()for consistency.
package selfupdate
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Codecov Report❌ Patch coverage is
... and 1 file with indirect coverage changes 🚀 New features to boost your workflow:
|
|



This pull request introduces a new self-update feature for the
decoderCLI, allowing users to check for and apply updates directly from the command line. It also improves build metadata handling and adds comprehensive tests for the new update logic and core helpers. The most important changes are grouped below.Self-update feature and CLI integration
updatesubcommand incmd/update.gothat checks for the latest release (optionally including release candidates) and replaces the running binary with the latest version, providing user feedback on success or failure.cmd/root.go, notifying users if a new version is available.selfupdatepackage import and supporting context usage to enable update logic in the CLI. [1] [2]Build and version metadata improvements
.goreleaser.yamlto inject build-time metadata (Version,Commit,Date) into the binary usingldflags, and configured release settings for proper draft/prerelease handling. [1] [2]cmd/version.goto define version and metadata variables that are set at build time.Testing and reliability
internal/selfupdate/selfupdate_test.goand supporting helpers ininternal/selfupdate/selfupdate_more_test.go, covering scenarios like release filtering, checksum validation, archive extraction, and error handling. [1] [2]pkg/common/helpers_more_test.go, improving reliability of payload validation and encoding routines.Dependency updates
golang.org/x/modas a new dependency ingo.modto support module operations required by the update logic.