2 ms·
This is a general property of most garbage collected languages - you don't know when a gc takes place (if ever) to run finalizers. For this reason Java has try
by danieldk 11y ago
This is a general property of most garbage collected languages - you don't know when a gc takes place (if ever) to run finalizers.
For this reason Java has try-with-resources, C# using, Haskell bracket and Go defer.
Note that you can attach a finalizer to a Go struct:
https://golang.org/pkg/runtime/#SetFinalizer https://golang.org/pkg/runtime/#SetFinalizer