go 调用函数 函数里边defer、log和调用函数层级 defer、log执行顺序
import (
"fmt"
"log"
)
func main() {
defer fmt.Println("DemoReturn-start")
s := DemoReturn(1)
fmt.Println(s)
log.Println("main-log1")
defer fmt.Println("DemoReturn-stop1")
defer fmt.Println("DemoReturn-stop2")
}
func DemoReturn(i int) int {
defer fmt.Println("DemoReturn1")
defer fmt.Println("DemoReturn2")
defer fmt.Println("DemoReturn3")
log.Println("DemoReturn-log1")
log.Println("DemoReturn-log2")
defer fmt.Println("DemoReturn4")
defer fmt.Println("DemoReturn5")
return i + 1
}