Files
go-study/main/pp.go
2024-08-01 23:40:06 +08:00

23 lines
305 B
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package main
import "fmt"
func main() {
tes()
}
func tes() int {
//利用defer+recover来捕获错误defer加匿名函数调用
defer func() {
err := recover()
if err != nil {
fmt.Println("错误已经捕获")
fmt.Println(err)
}
}()
num02 := 10
num01 := 0
return num02 / num01
}