logoalt Hacker News

kiitos06/04/20251 replyview on HN

errors.Is definitely doesn't use string comparison internally:

https://cs.opensource.google/go/go/+/refs/tags/go1.24.3:src/...


Replies

masklinn06/05/2025

Of course it does. What do you think an errors.New contains and how do you figure it compares by value when checking placeholder errors?

The answer is that errors.New just wraps the error message in an errorString struct, and the second line of `is` is a string comparison.

show 1 reply