Grokking Advanced Go
Vote

0% completed

​

Cleanups and Finalizers

The Go runtime can call a function of yours some time after an object becomes unreachable. Before relying on that, it helps to know exactly what the runtime does and does not promise.

The documentation of runtime.AddCleanup promises these things:

  • The function runs in a separate goroutine, and only after the object is no longer reachable.
  • Several cleanups may be attached to one object, and they may run at the same time.
  • A group of unreachable objects that point to each other does not stop a cleanup from running.

It does not promise these things:

.....

.....

.....

Like the course? Get enrolled and start learning!

Reading Progress

0%


Vote for new content