Go has a special statement called defer, which schedules a function to be called _____ the surrounding function returns.
- after
- before
- during
- instead of
In Go, the defer statement schedules a function to be called after the surrounding function returns. This is often used for tasks like closing files, releasing resources, or ensuring cleanup operations happen even in the presence of errors. When defer is used, the function call is deferred until the end of the enclosing function's scope, ensuring it runs just before that function returns.
Loading...