-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Consider dropping dependency on github.com/pkg/errors #3618
Comments
Unfortunately, Go's native error-wrapping is not a full replacement for pkg/errors, as it doesn't preserve a stack, which limits its usefulness. We are considering to propose maintainers for the https://github.com/pkg/errors package (pkg/errors#245 TBD); overall the package is "feature complete", so likely not much maintenance will be needed. /cc @tonistiigi Was there a specific reason you want the package to be removed? |
Nothing specific exactly, but two broad categories of reasons:
In any case, it's not an urgent need, and your answer is perfectly satisfactory. Especially so if you take on maintainership for it, since that would go toward solving (1) above. If you ever become interested in this, my offer to send a PR stands. 😄 |
Shameless plug: you can switch it to drop-in replacement BTW, go vet does complain on your example |
I concur that this needs to be removed, as the https://github.com/pkg/errors repository is now archived. As for the stack trace functionality, I guess, we need to re-assess the need of. If there is a consensus that it is really needed, come up with a solution which explicitly uses Go |
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. Some part of this change was done manually, and some changes were done by using github.com/AkihiroSuda/go-wrap-to-percent-w tool. In a few places this also: - changes '%s' or \"%s\" to %q; - removes extra context from the error message (such as, errors from os functions dealing with files do contain the file name already, and strconv.Atoi errors already contains the string which it failed to parse). Note that there is a single place which uses StackTrace functionality of pkg/errors, which is removed by this commit. A few remaining users of pkg/errors vendored here (directly and indirectly) are: - github.com/containerd/go-runc (needs to be bumped to v1.1.0); - github.com/microsoft/didx509go (needs microsoft/didx509go#19); - github.com/docker/cli (needs docker/cli#3618 fixed); - github.com/docker/docker (?) - github.com/linuxkit/virtsock (needs linuxkit/virtsock#69 merged); Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
There's a longer discussion here; Currently BuildKit enforces the use of pkg/errors, as it's essential for some error handling, but some discussion is on going to consider moving this functionality into https://github.com/containerd/errdefs. w.r.t. the https://github.com/pkg/errors repository being archived; I concur that's not ideal, OTOH, ISTR it was archived as "feature complete", so not necessarily problematic (currently). |
https://github.com/pkg/errors is deprecated, archived, and in maintenance mode, since Go errors natively support wrapping since Go 1.13.
There are about 200 files in this repo that depend on this package (excluding
vendor/
):It should be a fairly mechanical change:
errors.Wrap(err, "oh no")
becomesfmt.Errorf("oh no: %w", err)
errors.New("oh no")
becomeserrors.New("oh no")
, using the stdliberrors
package.errors.Errorf("oh %q", "no")
becomesfmt.Errorf("oh %q", "no")
It may even be somewhat possible to automate, using
x/tools/go/analysis
(see sigstore/cosign#1887 (comment)).Let me know if you'd be interested in considering a PR to make this change.
The text was updated successfully, but these errors were encountered: