首页 > 其他 > 详细

learn go defer

时间:2015-11-22 18:33:13      阅读:263      评论:0      收藏:0      [点我收藏+]
package main

// 参考文档:
//     https://github.com/Unknwon/the-way-to-go_ZH_CN/blob/master/eBook/06.4.md

import "fmt"

func main() {
    function1()
}

func function1() {
    fmt.Printf("In function1 at the top\n")
    defer function2()
    fmt.Printf("In function1 at the buttom\n")
}

func function2() {
    fmt.Printf("function2: Deferred until the end of the calling function!\n")
}

 

learn go defer

原文:http://www.cnblogs.com/zengjfgit/p/4986280.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!