Functions
Learn about functions in Go.
defer
statement
defer
statement doesn’t seem to have big traps, but it’s worth mentioning a few
nuances.
From an excellent post by Andrew Gerrand on the subject:
Note: A
defer
statement pushes a function call onto a list. The list of saved calls is executed after the surrounding function returns.defer
is commonly used to simplify functions that perform various cleanup actions.
The most important points to be aware of:
Get hands-on with 1400+ tech skills courses.