Re:Error handling in Go web apps shouldn't be so awkward
by Thaxll on Tuesday January 09, 2024 @09:26PM
(#38935382)
I've never seen or used reflection with error handling in Go, what do you mean?
[ Parent
| on HN ]
Re:Error handling in Go web apps shouldn't be so awkward
by Thaxll on Tuesday January 09, 2024 @09:30PM
(#38935403)
But this is a detail of implementation, user code does not use reflection with errors.
Re:Error handling in Go web apps shouldn't be so awkward
by sidlls on Tuesday January 09, 2024 @09:35PM
(#38935433)
That "detail of implementation" is what is used by user code, e.g., `myError.As(...)` uses reflection, implicitly.
Re:Error handling in Go web apps shouldn't be so awkward
by Thaxll on Tuesday January 09, 2024 @09:45PM
(#38935491)
Then what? It has 0 performance impact, we're talking about error handling here, it's rare and not in hot path.
Re:Error handling in Go web apps shouldn't be so awkward
by sidlls on Wednesday January 10, 2024 @09:19AM
(#38939242)
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.
Re:Error handling in Go web apps shouldn't be so awkward
by Thaxll on Wednesday January 10, 2024 @06:56PM
(#38945386)
No, it only executes when you enter the err != nil block so it's almost never called, again 0 impact on performance.
Re:Error handling in Go web apps shouldn't be so awkward
by derekperkins on Wednesday January 10, 2024 @12:41AM
(#38936645)
I wouldn't classify type assertion as reflection. It's a super fast type check of the object header, not dynamic reflection.