On Nov 9, 2:50 pm, "Jeff R. Allen" <
j...@nella.org> wrote:
> Just got bit by that, and so I thought I would mention it here. I'm
> trying to think if the docs could have saved me from this mistake, but
> it seems like it's just something you have to remember about defer:
> it's not magic, and once the process is dead, no defers happen.
It's precisely documented:
http://localhost:6060/doc/go_spec.html#Handling_panics
"When a function F calls panic, normal execution of F stops
immediately. Any functions whose execution was deferred by the
invocation of F are run in the usual way, and then F returns to its
caller. ..."
Calling os.Exit is not a panic call, so the defer guarantee above
doesn't apply.