feat: replace xerrors with standard Go error handling #108
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What changed? Why?
Removed the dependency on
golang.org/x/xerrors
throughout the codebase and refactored error handling to use the standardfmt.Errorf
function with the%w
verb for error wrapping, in combination with Go's built-inerrors
package for unwrapping and type assertion.Why xerrors is no longer needed
Since Go 1.13, the language has supported native error wrapping with
fmt.Errorf("...: %w", err)
, and since Go 1.20, the built-in error handling tools are mature enough to fully replacexerrors
. The key improvements include:fmt.Errorf
with%w
wraps errors effectively, allowing use oferrors.Is
anderrors.As
to inspect wrapped errors, matching the functionalityxerrors
previously offered.%+v
when needed, eliminating the need forxerrors
' custom formatting.xerrors
reduces external dependencies, improving maintainability and compatibility with future Go updates.How did you test the change?