2 ms·
It is not efficient, except at that one point in time you write the code. This is `errors.As`: https://cs.opensource.google/go/go/+/refs/tags/go1.19.4:src/erro
by sidlls 4y ago
It is not efficient, except at that one point in time you write the code.
This is `errors.As`: https://cs.opensource.google/go/go/+/refs/tags/go1.19.4:src/errors/wrap.go;l=78 https://cs.opensource.google/go/go/+/refs/tags/go1.19.4:src/.... It uses reflection and type assertions and itself contains error checking (e.g. to validate that the arguments are actually error interfaces).
It looks efficient in your code because the call is compact, but this is not even close to efficient, and especially not as efficient as a switch statement.