```go
import "fmt"
func main() {
defer func(){recover()}() //这个有效果, 为什么
//defer recover() //这个没有效果
fmt.Println("before")
panic("throw")
fmt.Println("after")
}
```
更多评论
规范有明确规定,recover 必须放在 defer 中,但是不能被 defer 直接调用。
>The return value of recover is nil if any of the following conditions holds:
>- panic's argument was nil;
>- the goroutine is not panicking;
>- recover was not called directly by a deferred function.
http://docs.studygolang.com/ref/spec#Handling_panics
#1