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

alias github.com/pkg/errors to pkgerrors #11848

Merged
merged 20 commits into from
Feb 27, 2024
Merged

Conversation

poopoothegorilla
Copy link
Contributor

@poopoothegorilla poopoothegorilla commented Jan 22, 2024

This PR is intended to reduce the burden on reviewing this PR #11818 which aims to reduce the dependency on multierr.

NOTES:

  • adds the alias pkgerrors for "github.com/pkg/errors"
  • does not aim to change anything else
  • will do another round of renaming the rest of the files in another PR
  • replace "cosmossdk.io/errors" with "github.com/pkg/errors"

reasons this is good.

  • having 3rd party packages share the same alias as standard pkg aliases can lead to assumptions on how pkgs function
  • since we intend to replace multierr by using the standard err package we have alot of places where naming collisions happen with github.com/pkg/errors

Avoid unnecessary package name collisions. While packages in different directories may have the same name, packages that are frequently used together should have distinct names. This reduces confusion and the need for local renaming in client code. For the same reason, avoid using the same name as popular standard packages like io or http.
https://go.dev/blog/package-names

Copy link
Contributor

I see that you haven't updated any README files. Would it make sense to do so?

@poopoothegorilla poopoothegorilla marked this pull request as draft January 22, 2024 22:42
samsondav
samsondav previously approved these changes Jan 23, 2024
jmank88
jmank88 previously approved these changes Feb 10, 2024
@archseer
Copy link
Contributor

pkg/errors should get removed altogether, it's been deprecated for years ever since go improved it's error system. https://github.com/pkg/errors?tab=readme-ov-file#roadmap

@archseer
Copy link
Contributor

archseer commented Feb 27, 2024

(pkgerrors.New -> errors.New, pkgerrors.Wrap(...) -> fmt.Errorf("my text: %v", ...) etc)

Additionally we should deny importing pkg/errors in golangci-lint config.

@jmank88
Copy link
Contributor

jmank88 commented Feb 27, 2024

pkg/errors should get removed altogether, it's been deprecated for years ever since go improved it's error system. pkg/errors#roadmap

I agree but we have some hold outs for the stack traces that want a replacement.

@jmank88
Copy link
Contributor

jmank88 commented Feb 27, 2024

(pkgerrors.New -> errors.New, pkgerrors.Wrap(...) -> fmt.Errorf("my text: %v", ...) etc)

Additionally we should deny importing pkg/errors in golangci-lint config.

Is that a thing? I have been hacking on this: #11697

@archseer
Copy link
Contributor

Yep! Denying pkg/errors is even a lint example https://golangci-lint.run/usage/linters/#depguard

@poopoothegorilla
Copy link
Contributor Author

@archseer do you have any recommendations for how we can replace the stack traces? Thats the big blocker for us taking it out

@jmank88
Copy link
Contributor

jmank88 commented Feb 27, 2024

@archseer do you have any recommendations for how we can replace the stack traces? Thats the big blocker for us taking it out

I have a hack somewhere that adds file and line number caller info to wrapped errors so that you end with something a little more stacktrace-like.

We still have stacktraces for zap logs at error and above too.

@jmank88 jmank88 added this pull request to the merge queue Feb 27, 2024
Merged via the queue into develop with commit e37f7e2 Feb 27, 2024
98 checks passed
@jmank88 jmank88 deleted the jtw/rename-pkg-errors branch February 27, 2024 23:19
@dimriou dimriou mentioned this pull request Mar 4, 2024
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.

4 participants