Go defer keyword

The defer keyword is generally used for cleaning purpose. The defer keyword postpones the execution of a function or statement until the end of the calling function.

It executes code (a function or expression) when the enclosing function returns before the closing curly brace }. It is also executed if an error occurs during the execution of the enclosing function.

Go defer Example

Output:

there
Hi... 

Next TopicGo Panic




Contact US

Email:[email protected]

Go Defer
10/30