Introduction
Defer lets you delay running a piece of code until the surrounding function finishes. It helps clean up resources in the right order.
Closing a file after reading or writing
Unlocking a mutex after locking it
Releasing a network connection after use
Printing a message after a function ends
Cleaning up temporary resources in reverse order