Re: [go-nuts] Error-checking with errors.As() is brittle with regards to plain vs pointer types

2022-09-22 Thread 'Sean Liao' via golang-nuts
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 wrote: > Consider https://go.dev/play/p/jgPMwLRRsqe: > > errors.As(err, ) will not

[go-nuts] Error-checking with errors.As() is brittle with regards to plain vs pointer types

2022-09-21 Thread cpu...@gmail.com
Consider https://go.dev/play/p/jgPMwLRRsqe: errors.As(err, ) 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