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
replace deprecated package github.com/pkg/errors #28
Conversation
Codecov Report
@@ Coverage Diff @@
## master #28 +/- ##
=======================================
Coverage 79.47% 79.47%
=======================================
Files 5 5
Lines 268 268
=======================================
Hits 213 213
Misses 38 38
Partials 17 17
Continue to review full report at Codecov.
|
Hi, thanks, but I'm not sure this is backwards compatible. If there were people relying on github.com/pkg/errors.Cause(), I think this would break their code -- i.e. I think we'd have to bump major versions go with this change. So that's a showstopper to merging this PR, at least not at this point, and not to |
I was thinking about that, my understanding of how errors.Cause works is based on this documentation:
In which case, it should return the outermost error. Is there a place where an underlying error type is made public? On my examination of the package it appeared there were no existing exported error types (or any other types) as package variables or constants. If there's a way someone was using Cause() to get at an underlying type, totally agree, I just couldn't find that possibility when looking through the code, but very possible I missed something. UPDATE: Looking at the archived code for pkg/errors, I think this case might actually be handled natively in pkg/errors. In pkg/errors#215 looks like pkg/errors introduced support for go1.13 native wrapped error chains to |
Ah yes, it looks like the fix was later reverted in pkg/errors#220. Sorry I missed that. Whats your personal appetite like on eventually rolling a |
From my PoV:
So I'm not against v2 or your change per se, but ATM I don't have a compelling reason to bump the version or to eradicate github.com/pkg/errors The other possibility to eradicate github.com/pkg/errors that I can think of is to gradually change the behavior -- perhaps with build tags:
I guess this approach would be up to me, but again, I don't have a compelling reason. So I guess it comes down to: Is there a concrete problem that you are facing by this module using github.com/pkg/errors, other than the fact that it's archived? |
For my general professional use case, we do audit all dependencies, and the active maintenance/governance of a project is one portion the a selection criteria (as well as generally try to reduce the dependency chain where possible to minimize risk). In this particular instance however, my usage was currently for a side project and thus I was only trying to help clean things up for best practice -- prior to recognition of the reverse incompatibility issue. Thus I don't believe my usage should be a particular factor in your decision (and I could always just maintain my own fork if really needed). A v2 bump would likely be most compelling if there were other changes you wanted to make at the same time. |
fair enough. let's see if we can do a gradual transition then. would you be willing to do the following? (feel free to tell me no if you're not up to it)
|
Sure, I'll take a stab at that. (Might have to chip away at it here and there as I'm traveling for business next few weeks, but will try to make incremental progress.) |
This tests back from the version specified in go.mod to current stable. This should enable detection of any breaking version changes as part of the dependencies update PR. subtask forked from lestrrat-go#28.
This tests back from the version specified in go.mod to current stable. This should enable detection of any breaking version changes as part of the dependencies update PR. subtask forked from lestrrat-go#28.
* build(ci): test matrix include go1.12 up to go1.18 This tests back from the version specified in go.mod to current stable. This should enable detection of any breaking version changes as part of the dependencies update PR. subtask forked from #28. * build(ci): disable fail-fast to test all go versions * build(ci): bump version of golangci-lint to v1.45.2
I foolishly based this original PR off of |
replaces github.com/pkg/errors, which is now marked as archived and not maintained on github, with native >=go1.13 standard library functions. This preserves the error wrapping previously handled via errors.Wrap via the new %w directive in fmt.Errorf.
Okay, this PR now represents the work for task "one" above. It cherry-picked contains my original commit for factoring out pkg/errors, which will be updated to reflect the new strategy in subsequent commits. This also makes visible in CI that we would be breaking go1.12 compatibility where depending on the new stdlib errors functionality, so that can be planned for and discussed. I'll start on the internal errors package in the future (but feel free to push changes to this PR directly if you don't want to wait for me). |
Sure. I'll take it from here then |
Replaces
github.com/pkg/errors
, which is now marked as archived and no longer maintained on github, with native >=go1.13 standard library functions. This preserves the error wrapping previously handled viaerrors.Wrap
via the new%w
directive infmt.Errorf
.This makes the minimum go version go1.13, so thus update the go.mod to reflect and also updates the test matrix here to test from go1.13-go1.18 inclusive (previously tested go1.14-go1.15).