-
Notifications
You must be signed in to change notification settings - Fork 569
Closed
Labels
Description
It might sound strange, but I'd like some way to hook into mainFinished
- kind of as a finalizer.
The Node.js runtime can block program termination with object refs. See net.Socket.ref/net.Socket.unref for example. This is useful for shutting down keep-alive connections.
I'd like to call "unref" on mainFinished to close down any sockets when all of the Go code has finished executing. I can explain in more detail if it still doesn't make sense.
runtime.AddProgramFinalizer(func())
runtime.OnMainFinished(func())
Essentially:
$mainFinished = true;
for (var i = 0; i < $mainFinishers.length; i++) {
$mainFinishers[i]();
}