标签:
defer 作用:
package main import ( "fmt" ) func begin(funName string) string { fmt.Println("Enter Function") return funName } func end(funName string) string { fmt.Println("Leave Function") return funName } func record() { fmt.Println("Run Function") } func main(){ defer end(begin("func")) record() }
输出为:
Enter Function
Run Function
Leave Function
标签:
原文地址:http://www.cnblogs.com/hellobiek/p/4948864.html