Radar · Go · Archive · Week 9 · Feb 24 – Mar 2, 2025
runtime: allow cleanups to run concurrently
Worth knowingruntime
- What changed
- Documentation for
runtime.AddCleanupwas updated to state that cleanups run concurrently with user goroutines and with each other. - Production impact
- The source does not say.
- Try it
- Call
runtime.AddCleanupfrom multiple goroutines and observe concurrent execution. - Source
- github.com/golang/go/issues/71825
Understand it, then run it
The runtime.AddCleanup function lets a program register a function that will run when the program exits. Until recently the documentation said that all cleanup functions run in a single goroutine, one after another. The change removes that wording and says that cleanups now run concurrently with each other and with user goroutines. This means a long‑running cleanup will no longer block other cleanups or the rest of the program.
Written by gpt-oss-20b from the linked source · claims checked against the sources · archive, not individually reviewed