Opened https://github.com/golang/go/issues/47528
On Monday, August 2, 2021 at 6:30:04 PM UTC+2 Andreas Götz wrote:
> > Because both are of type `*errors.errorString`, so the types match and
> it copies over the value.
> Arguably, `errors.errorString` should implement `As()` and return `false`,
> Because both are of type `*errors.errorString`, so the types match and it
copies over the value.
Arguably, `errors.errorString` should implement `As()` and return `false`,
unless the pointers match. I suggest filing an issue.
Will do. It could also be a vet check to highlight errors.As used on
On Mon, Aug 2, 2021 at 10:02 AM cpu...@gmail.com wrote:
> Consider this example: https://play.golang.org/p/16cU0kc8Lku, basically
>
> var Err = errors.New("sentinel")
> err := errors.New("foo")
> if errors.As(err, &Err) {
> fmt.Println("why?")
> }
>
> I'm wondering why this matches the sentinel
Consider this example: https://play.golang.org/p/16cU0kc8Lku, basically
var Err = errors.New("sentinel")
err := errors.New("foo")
if errors.As(err, &Err) {
fmt.Println("why?")
}
I'm wondering why this matches the sentinel error, or rather how to
properly use sentinel errors. errors.As says "An