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

cleanup: don't use pkg/errors #4691

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

Conversation

imjasonh
Copy link
Contributor

@imjasonh imjasonh commented Dec 4, 2023

- What I did

Replaced uses of github.com/pkg/errors in this repo.

That package has been archived for 2 years, after fmt.Errorf added support for wrapping errors with %w in Go 1.13, more than 3 years ago.

There are still indirect dependencies on pkg/errors via github.com/docker/docker -- I can try to clean those up as well, if you're interested.

- How I did it

Mostly I ran this: https://github.com/zchee/go-analyzer/tree/main/pkgerrors

pkgerrors -fix ./...

In order to get that to work though, I first needed to find cases where errors.Wrap was called like errors.Wrap(err, msg) (where msg is an identifier and not a const string expression) or errors.Wrap(err, foo()) (where foo is a method call and not a const string expression).

After that I replaced any remaining errors.Is calls to use Go's stdlib errors.Is, which now works with the %w added by the analyzer

- How to verify it

Thorough code review and reliance on tests

- Description for the changelog

Remove use of deprecated/archived module github.com/pkg/errors

TODO (if you're interested in proceeding)

  • fix lint findings now that fmt.Errorf with capitalized message trips the linter
  • do github.com/docker/docker too

Signed-off-by: Jason Hall <[email protected]>
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.

1 participant