Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The first 3 lines of `errors.Is()` [0] are the following:

  if err == nil || target == nil {
    return err == target
  }
[0]: https://github.com/golang/go/blob/9b43bfbc51c469ec13fca24960...


Glad to know they have fixed this. In Go 1.22.3 (the latest release), the first 3 lines of `errors.is` [0] are the following:

    if target == nil {
      return err == target
    }
[0]: https://github.com/golang/go/blob/go1.22.3/src/errors/wrap.g...


That's interesting, because I ran the benchmarks on that version of Go.


The `err == nil` check was added in April to avoid expensive and unnecessary reflection. Perhaps 1.23, or whichever release that ends up in, would be faster?

https://github.com/golang/go/commit/af43932c20d5b59cdffca454...




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: