Replace xerrors with fmt.Errorf - #107
Conversation
Replace usages of golang.org/x/xerrors with the standard library fmt.Errorf across the project. Updated imports to add fmt where needed, adjusted tests to use fmt.Errorf, and removed the xerrors dependency from go.mod/go.sum. This simplifies error handling by relying on the standard library's %w error wrapping and removes an external dependency.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #107 +/- ##
=======================================
Coverage 90.14% 90.14%
=======================================
Files 38 38
Lines 1695 1695
=======================================
Hits 1528 1528
Misses 116 116
Partials 51 51 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This pull request removes the external dependency on golang.org/x/xerrors and replaces it with the standard library's fmt.Errorf function, which has supported error wrapping with %w since Go 1.13. This simplifies the codebase by eliminating an external dependency while maintaining identical error handling semantics.
Changes:
- Replaced all
xerrors.Errorfandxerrors.Newcalls withfmt.Errorfacross 11 Go files - Added
fmtimport to files where it was needed - Removed
golang.org/x/xerrorsdependency from go.mod and go.sum
Reviewed changes
Copilot reviewed 12 out of 13 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| up.go | Replaced xerrors with fmt.Errorf for service creation and waiting errors |
| task_definition_test.go | Updated test mocks to use fmt.Errorf instead of xerrors.New |
| task/simple_task.go | Replaced xerrors error formatting for canary task failures |
| task/common.go | Replaced all xerrors calls with fmt.Errorf for task management errors |
| task/alb_task.go | Replaced xerrors with fmt.Errorf and refactored if-else to switch statement |
| run.go | Updated all error messages to use fmt.Errorf for task execution errors |
| rollout.go | Replaced xerrors with fmt.Errorf for rollout validation and execution errors |
| env/env.go | Updated environment validation and file loading errors to use fmt.Errorf |
| cli/cage/upgrade/upgrade.go | Replaced xerrors with fmt.Errorf for upgrade-related errors |
| cli/cage/prompt/prompt.go | Updated prompt confirmation errors to use fmt.Errorf |
| cli/cage/commands/command.go | Replaced xerrors with fmt.Errorf for argument validation |
| go.mod | Removed xerrors dependency |
| go.sum | Removed xerrors dependency checksums |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Replace usages of golang.org/x/xerrors with the standard library fmt.Errorf across the project. Updated imports to add fmt where needed, adjusted tests to use fmt.Errorf, and removed the xerrors dependency from go.mod/go.sum. This simplifies error handling by relying on the standard library's %w error wrapping and removes an external dependency.