HN
Hacker News
Top
New
Best
Ask
Show
Jobs
Comment by sidlls | Hacker News Reader
Parent
Full thread
sidlls
·
https://cs.opensource.google/go/go/+/refs/tags/go1.21.6:src/...
View on HN
derekperkins
·
I wouldn't classify type assertion as reflection. It's a super fast type check of the object header, not dynamic reflection.
Thaxll
·
But this is a detail of implementation, user code does not use reflection with errors.
sidlls
·
That "detail of implementation" is what is used by user code, e.g., `myError.As(...)` uses reflection, implicitly.
Thaxll
·
Then what? It has 0 performance impact, we're talking about error handling here, it's rare and not in hot path.
sidlls
·
It does not have 0 performance impact, it's not rare, and in applications that are in the hot path, error handling is
also
in the hot path.
Thaxll
·
No, it only executes when you enter the err != nil block so it's almost never called, again 0 impact on performance.
Reply on news.ycombinator.com