Better HN
top
new
best
ask
show
jobs
Log in
Sign up
Better HN
Comment
by
JulianMorrison
· 8y ago · 0 comments
Defer also runs in the case of a panic. So it's not just a hidden goto.
Comments
[–]
32bitkid
8y ago
more detail on why `defer` can/is more expensive (and not equivalent) to unrolling it:
https://blog.golang.org/defer-panic-and-recover
[–]
arendtio
8y ago
Thanks, that is what I was looking for. I used defer just as convenience and wasn't aware (anymore) that it does something different than just pushing the function call to the end. Maybe it's time to take the Golang tour again ;-)