```go
package main
import "fmt"
func test(){
defer func() {
err := recover()
if err != nil {
fmt.Print("err=",err)
}
}()
r := 2/0 //没执行到recover,输出# command-line-arguments、division by zero
/*下面2行能执行到recover,请问是为啥?
var a,b int = 1,0
r := a/b
*/
fmt.Println("r:",r)
}
func main(){
test()
fmt.Println("\n执行结果")
}
```
有疑问加站长微信联系(非本文作者)