The documented api includes

> An error matches target if the error's concrete value is assignable to
the value pointed to by target

*T is not assignable to T

- sean

On Wed, Sep 21, 2022, 20:26 cpu...@gmail.com <cpui...@gmail.com> wrote:

> Consider https://go.dev/play/p/jgPMwLRRsqe:
>
> errors.As(err, <plain type>) will not match if error is of pointer type.
> As a result, a library consumer needs to understand if a library returns
> Error or *Error. However, that is not part of the API spec as both returns
> would satisfy error if Error() is implemented on the plain type.
>
> A potential workaround would be using Error.As(any) to match plain/pointer
> type as part of the library. However, it seems counterintuitive having to
> do so if errors.As() doesn't by default.
>
> Would it make sense (and I would like to propose) to expand errors.As() to
> match plain receiver types even when err is a pointer to the same
> underlying plain type.
>
> What do you think?
>
> Cheers,
> Andi
>
> --
> 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/9c5fe0fb-de0c-4c09-b884-2f8153348fb7n%40googlegroups.com
> <https://groups.google.com/d/msgid/golang-nuts/9c5fe0fb-de0c-4c09-b884-2f8153348fb7n%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/CAGabyPo%3DK%2B7EcTgRQN%3DDNjUUWNv5cBj5xS_Gw53kCuppvyL0gQ%40mail.gmail.com.

Reply via email to