mirror of
https://github.com/unknwon/the-way-to-go_ZH_CN.git
synced 2025-08-12 01:55:35 +08:00
update book code
This commit is contained in:
17
eBook/examples/chapter_6/defer.go
Normal file
17
eBook/examples/chapter_6/defer.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
Function1()
|
||||
}
|
||||
|
||||
func Function1() {
|
||||
fmt.Printf("In Function1 at the top\n")
|
||||
defer Function2()
|
||||
fmt.Printf("In Function1 at the bottom!\n")
|
||||
}
|
||||
|
||||
func Function2() {
|
||||
fmt.Printf("Function2: Deferred until the end of the calling function!")
|
||||
}
|
Reference in New Issue
Block a user