`defer` in Go is a hidden memory allocation. It pushes to a function-level stack of defers allocated on the heap. This is problematic if you, for example, want to use defer to unlock a mutex. In D and Zig `defer` does not secretly allocate memory and is block-scoped.https://twitter.com/erikcorry/status/1098229826987659265 …
IIRC this is because of the interaction between defer and panic. Deferred functions can panic themselves, so properly unwinding the stack is nontrivial.