Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch from github.com/pkg/errors to %w-style wrap #5525

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

kolyshkin
Copy link
Contributor

@kolyshkin kolyshkin commented Oct 9, 2024

The github.com/pkg/errors is mostly obsoleted since Go 1.13 introduced %w-style error wrapping. It is also not maintained and is now archived by the owner.

Fixes: #3618

- What I did

- How I did it

Mostly by using https://github.com/AkihiroSuda/go-wrap-to-percent-w tool.
In some cases, by hand.

- How to verify it

I hope CI is adequate.

- Description for the changelog

Switch from github.com/pkg/errors to %w-style error wrapping.

- A picture of a cute animal (not mandatory but encouraged)

The github.com/pkg/errors is mostly obsoleted since Go 1.13 introduced
%w-style error wrapping. It is also not maintained and is now archived
by the owner. Let's switch to %s-style error wrapping.

Changes here are done by hand, touching code code which is not handled
correctly by the go-wrap-to-percent-w tool. The reason being,
errors.Wrap(err, "text") returns nil when err is nil, while
fmt.Errorf("text: %w", err) returns non-nil even if err is nil.

Signed-off-by: Kir Kolyshkin <[email protected]>
The github.com/pkg/errors is mostly obsoleted since Go 1.13 introduced
%w-style error wrapping. It is also not maintained and is now archived
by the owner. Let's switch to %s-style error wrapping.

Generated by

	git ls-files *.go | grep -v '^vendor/' | xargs go-wrap-to-percent-w -w

using https://github.com/AkihiroSuda/go-wrap-to-percent-w tool.

Signed-off-by: Kir Kolyshkin <[email protected]>
1. Ditch wrapAsPluginError as we can simply use NewPluginError now.

2. Add a TODO to remove pluginError.Cause method.

3. Stop referring to pkg/errors method (except for 2 above).

Signed-off-by: Kir Kolyshkin <[email protected]>
@codecov-commenter
Copy link

codecov-commenter commented Oct 10, 2024

Codecov Report

Attention: Patch coverage is 33.67876% with 256 lines in your changes missing coverage. Please review.

Project coverage is 60.54%. Comparing base (305985c) to head (8eb1567).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5525      +/-   ##
==========================================
- Coverage   60.58%   60.54%   -0.05%     
==========================================
  Files         345      345              
  Lines       23456    23465       +9     
==========================================
- Hits        14211    14207       -4     
- Misses       8273     8284      +11     
- Partials      972      974       +2     

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consider dropping dependency on github.com/pkg/errors
2 participants