go try。。。catch
package main
import "fmt"
func main() {
item := []int{1, 2, 4, 0, 8}
for _, val := range item {
calcu(val)
}
}
func calcu(val int) {
defer func() {
err := recover()
if err != nil {
fmt.Println(err)
}
}()
res := 8 / val
fmt.Println(res)
}