In my opinion, this is a much nicer errors package than Go's library, and I've been using it everywhere: https://github.com/pkg/errors
Instead of fmt.Errorf("%w"), you do errors.Wrap(err, "message"), and errors.Unwrap(...) where you want to inspect the error. It's much more explicit and less error prone. -- Marcin On Sun, Mar 22, 2020 at 1:06 PM Adrian Ratnapala <adrian.ratnap...@gmail.com> wrote: > Part of the culture of Go is that we are careful to promise as little > as possible in APIs, as we will be stuck with those promises long into > the future. > > Now with Go 1.13 we can do `fmt.Errorf("It broken: %w")` which means > the same thing as `fmt.Errorf("It broken: %v")` except callers get > better ways to inspect the result. But as the Go blog says, this > means the use of "%w" becomes a way to expose an API: > > > In other words, wrapping an error makes that error part of your API. If > you don't want to commit to supporting that error as part of your API in > the future, you shouldn't wrap the error. > > Given the preference for *not* introducing APIs, doesn't that mean > authors should stick to "%v" until they have clear reasons for using > "%w". After all, it's always possible to switch to "%w" later. > > > -- > Adrian Ratnapala > > -- > 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/CAN%2BHj7jgoMSoyTpcOL%3Da2Rd51MvO%2Bgp0XRzTHjtNZcqPdK8zOg%40mail.gmail.com > . > -- 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/CA%2Bv29Lv46BU2D_gezT-urrzP5%3D1ZXjdn8NgWxYs0RBk%2BK1UMhw%40mail.gmail.com.