This website uses strictly necessary cookies & statistics cookies to provide functionality and to analyze traffic.
The defer statement actually has 3 types: open-coded defer, heap-allocated defer, and stack-allocated. Each one has different performance and different scenarios where they’re best used, which is good to know if you want to optimize performance.