In the first case, you ask if the respective errors wrap e1. The answer is yes - both wrap e1. In the second case, you ask if one error wraps the other. The answer is no - they both wrap ErrInvalidArgument, but they don't wrap each other. errors.Is doesn't check if both errors passed wrap the same error - they check if the first argument wraps the other.
On Sun, May 1, 2022 at 4:56 PM Tong Sun <suntong...@gmail.com> wrote: > Please take a look at > https://go.dev/play/p/Dl_IGD46bPe > > I have two error wrappings there, one works and one doesn't (I'm expecting > both to be the "Same"). Why one works and one doesn't? > > thanks > > -- > 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/3a1c9ad1-8d7c-481a-bfbb-4d4c94cc8f72n%40googlegroups.com > <https://groups.google.com/d/msgid/golang-nuts/3a1c9ad1-8d7c-481a-bfbb-4d4c94cc8f72n%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- 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/CAEkBMfGTQD3c-qeymnrqdoAW-VCzsvAGrO33Y26b49Z8XF%2BhMg%40mail.gmail.com.