Each time a “defer” statement executes, the function value and parameters to the call are evaluated as usual and saved anew but the actual function is not invoked.
So by adding a layer of indirection in the second example, only the outer function is evaluated at the time you add it to the stack (not the call to t.Log). As a new gopher, it’s good to be careful/deliberate about defer statements (along with similar gotchas in goroutines!).