Defer

  • Published on
    关于`defer` Golang 官方博客专门发文[介绍过三条规则](https://blog.golang.org/defer-panic-and-recover): > 1. defer语句被求值时,被defer调用的函数参数即时求值 A deferred function's arguments are evaluated when the defer statement is evaluated. `Defer statements`的[Spec](https://golang.org/ref/spec#Defer_statements)中有这么一句描述: > 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. ...