Hjertnes.wiki

Defer

Golang has this awesome keyword called defer. What a deferred function call does is to call it as late as possible before the function exists. Very useful for closing database connections and files and stuff like that.

And the pattern of opening a resource and immedialty calling defer closeIt() makes it much clearer to be than having to look for a close statement later.