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.

阅读更多

那些意外变成特性的 Bug:当代码漏洞改写计算史

那些意外变成特性的 Bug:当代码漏洞改写计算史

那些意外变成特性的 Bug:当代码漏洞改写计算史. 比起草台班子将错就错的神话,面对异常数据时的观测定力才是真的 社交网络上常年流传着一类爽文:某家公司的程序员把代码写崩了,结果不仅没被开除,这个 Bug 反而成了拳头产品,妥妥的爽文主角剧本。 最常被搬出来的有三个:Audio Hijack 写错试用期拯救公。

By huizhou92