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

Replace github.com/pkg/errors with fmt? #98

Open
gary-lgy opened this issue Jun 9, 2023 · 2 comments
Open

Replace github.com/pkg/errors with fmt? #98

gary-lgy opened this issue Jun 9, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@gary-lgy
Copy link
Member

gary-lgy commented Jun 9, 2023

The former has not been maintained since 2021.
The latter is not a complete replacement of the former, because the former adds stack traces to errors. However, we are not making use of stack traces in errors.

Should we replace the former with the latter?

@SOF3
Copy link
Member

SOF3 commented Jun 9, 2023

There are several things we can improve about errors altogether:

  • Interaction with tracing
  • Structural errors
  • Exposing errors to metrics
  • Unify error format

We can improve all of these together with comparable time investment.

@gary-lgy gary-lgy added the enhancement New feature or request label Jul 6, 2023
@mitar
Copy link

mitar commented Oct 9, 2023

Shameless plug: you can also switch it to drop-in replacement gitlab.com/tozd/go/errors. It fixes many issues, is maintained, and supports modern Go's error patterns (sentinel errors, %w formatting, joined errors, etc.). It also provides some nice utility functions and structured details so that it is easy to extract dynamic data out of errors (instead of trying to get them out of formatted strings). Has improved error formatting and JSON marshaling of errors. It is interoperable with other errors packages and does not require a dependency on it to extract data (e.g., stack trace) from errors.

From the list above, it provides structural errors and unified error formatting (even for errors which come from other errors packages/approaches so it works well in large codebases with mixed errors dependencies). Because it supports structural errors (called details) it is also easy to add metrics to errors. And JSON support helps with logging storage.

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

No branches or pull requests

3 participants