menuet
menuet copied to clipboard
defer functions doesn't execute when application exit
Hi, thanks for this cool library, this awesome, and exactly what I need. But I see that we exit the application from native code, so it breaks golang spec - we can't execute defer functions :(
Can you please give a point on how to fix it?
Interesting, thanks for the report.
This will probably require some experimentation. It may be that inside menuet.m's applicationShouldTerminate (https://github.com/caseymrm/menuet/blob/master/menuet.m#L225) we need to call back into go to clean up before returning NSTerminateNow.
Based on this: https://stackoverflow.com/questions/27629380/how-to-exit-a-go-program-honoring-deferred-calls this might be as simple as calling runtime.Goexit(), or maybe we would need to do the panic/recover mentioned in a later answer.
(This might also require making sure applicationWillTerminate is set to NO in your Info.plist, because nothing is ever easy.)
Fixed by #20?