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:
22
eBook/examples/chapter_6/defer_tracing.go
Normal file
22
eBook/examples/chapter_6/defer_tracing.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func trace(s string) { fmt.Println("entering:", s) }
|
||||
func untrace(s string) { fmt.Println("leaving:", s) }
|
||||
|
||||
func a() {
|
||||
trace("a")
|
||||
defer untrace("a")
|
||||
fmt.Println("in a")
|
||||
}
|
||||
|
||||
func b() {
|
||||
trace("b")
|
||||
defer untrace("b")
|
||||
fmt.Println("in b")
|
||||
a()
|
||||
}
|
||||
func main() {
|
||||
b()
|
||||
}
|
Reference in New Issue
Block a user