3 ms·
Actually, not only are you right about your errdefer Go implementation - but that's actually fairly common in Go code. Especially for tracing/logging of errors
by slimsag 5y ago
Actually, not only are you right about your errdefer Go implementation - but that's actually fairly common in Go code.
Especially for tracing/logging of errors returned from functions; or for e.g. rolling back DB transactions in the event of an error.
Here's some ~100 examples from my work's (Sourcegraph's) codebase[0]
[0] https://sourcegraph.com/search?q=context:global+repo:%5Egithub%5C.com/sourcegraph/sourcegraph%24+defer+func%28%29+%7B%5Cn.*if+err+%21%3D+nil+count:all&patternType=regexp https://sourcegraph.com/search?q=context:global+repo:%5Egith...