Good catch — you’re right.

My general point about errors.Is and wrapped sentinel errors still stand, but io.EOF is a special case. The io docs explicitly say that…

分享

Good catch — you’re right.

My general point about errors.Is and wrapped sentinel errors still stand, but io.EOF is a special case. The io docs explicitly say that Read must return io.EOF itself, not a wrapped form, because callers often compare it with ==.

So io.EOF was a poor example there. I’ve updated the demo to use a different sentinel error and will call out io.EOF as an exception.

Thanks for pointing it out.