Hi! Yes, I have. My view is that both github.com/pkg/errors and gitlab.com/tozd/go/errors aim at being more or less a drop-in replacement for core errors, but adding stack traces to errors. Since Go has now Errorf which can wrap existing errors to augment their messages, the utility functions in github.com/pkg/errors and gitlab.com/tozd/go/errors are not really necessary, but they still make some common cases easy. So my view is that these two packages could be something which could be used in a wide range of packages to produce errors, when the package also wants to return a stack trace with the error.
On the other hand, github.com/cockroachdb/errors has so many features that to effecticelly use it one has to coordinate around the codebase how exactly different features are used to get consistency. So it is less useful in my opinion for 3rd party packages and more as something you would use in your own large codebase (which you more or less control). But it has all possible features you might ever want. Maybe it could be cool if github.com/cockroachdb/errors would be built on top of gitlab.com/tozd/go/errors, to use when you need all those additional features. Additionally, I am personally not too convinced about storing end-user hints into errors themselves. Maybe that works for some people, but to me errors are something useful to control program flow and to debug by developers, while showing hints to end users is generally something one has to do separately (e.g., because you have to translate that hint anyway to the user's language). So to me a pattern I prefer, and gitlab.com/tozd/go/errors enables, is to have a set of base errors (e.g., io.EOF) which you then augment with the stack trace at the point where they happen, and then when you are handling errors you use `errors.Is` to determine which of base errors happened and map that to a message for the end user, in their language. So in a way, github.com/cockroachdb/errors has too much stuff for me, so I prefer something leaner. Mitar On Mon, Jan 3, 2022 at 7:27 AM Gaurav Maheshwari <gaurav.m.i...@gmail.com> wrote: > > Did you check https://github.com/cockroachdb/errors ? How does it differ from > cockroachdb/errors? > > On Mon, 3 Jan 2022 at 08:05, Mitar <mmi...@gmail.com> wrote: >> >> Hi! >> >> I have recently published a new package which provides errors with a >> stack trace, similar to now archived github.com/pkg/errors, but >> attempting to address many issues the community has identified since >> and updating it to new Go features. It is almost compatible with >> github.com/pkg/errors codewise and very familiar human wise. >> >> Now you can use Errorf to both wrap an existing error, format the >> error message, and record a stack trace. >> >> https://gitlab.com/tozd/go/errors >> >> Check it out. Any feedback is welcome. >> >> >> Mitar >> >> -- >> http://mitar.tnode.com/ >> https://twitter.com/mitar_m >> >> -- >> You received this message because you are subscribed to the Google Groups >> "golang-nuts" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to golang-nuts+unsubscr...@googlegroups.com. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/golang-nuts/CAKLmikOVd%3DaV01QQf8xUE5vOxqarz7dsrit0V3pgT_XsaQuGow%40mail.gmail.com. > > > > -- > Gaurav Maheshwari -- http://mitar.tnode.com/ https://twitter.com/mitar_m -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAKLmikPuEWo9uWvXK_A7yq6F6%2BwLzV_hrrD7Kt1pfbPzWMqp6Q%40mail.gmail.com.