首页 > 其他分享 >defer执行顺序和return先后顺序

defer执行顺序和return先后顺序

时间:2022-08-28 15:46:00浏览次数:71  
标签:defer 先后顺序 return fmt go Println main

image-20220828153126496

package main

import "fmt"

func main() {
   //写入defer关键字
   defer fmt.Println("main end1")
   defer fmt.Println("main end2")


   fmt.Println("main::hello go 1")
   fmt.Println("main::hello go 2")
}

标签:defer,先后顺序,return,fmt,go,Println,main
From: https://www.cnblogs.com/suehoo/p/16632855.html

相关文章