#golang #tip If you want to call some function such as context cancellation in a retry loop which has multiple branches, use a defer with a closure. It scopes the defer cleanly and ensures that the context is cancelled in each code branch.