On Sat, Oct 15, 2016 at 10:16 PM, <d...@veryhaha.com> wrote: > > On Saturday, October 15, 2016 at 6:37:08 PM UTC+8, Hotei wrote: >> >> re "meaningfullness" - I think he's saying that a finalizer for a function >> called in a goroutine might not run if main() quits first, intentionally or >> otherwise. You can of course check for this specific case by making sure >> all your goroutines are cleaned up before exiting main - but in some (many?) >> cases that's overkill. >> >> If it's REALLY important to know which finalizer actions completed you >> could log them to disk and analyse the results afterwards to see that all >> the boxes got checked. Not quite what the OP was looking for I know - but >> might help diagnose problems. > > > > Can you enum any use cases of SetFinalizer? I mean the use cases where > alternative solutions would do worse than SetFinalizer.
SetFinalizer is useful when a Go value ties up resources that are not themselves part of the Go program--they are part of some non-Go code liked into the Go program, or they are some external resource. If the lifespan of the Go value is unclear--if it is passed around to several different goroutines with no clear point where it is explicitly released--then a finalizer can be a useful way to release the external resource. Ian -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.