This commit is contained in:
Unknown
2014-09-23 22:46:45 -04:00
parent d480e2db2d
commit d90f7364d4
5 changed files with 35 additions and 6 deletions

View File

@@ -8,7 +8,7 @@
```go
package main
import fmt
import "fmt"
func main() {
Function1()
@@ -130,8 +130,8 @@ ok, disconnected from db
一个基础但十分实用的实现代码执行追踪的方案就是在进入和离开某个函数打印相关的消息,即可以提炼为下面两个函数:
```go
func trace(s string) { fmt.Println("entering:", s) }
func untrace(s string) { fmt.Println("leaving:", s) }
func trace(s string) { fmt.Println("entering:", s) }
func untrace(s string) { fmt.Println("leaving:", s) }
```
以下代码展示了何时调用两个函数:
@@ -234,4 +234,10 @@ func main() {
输出:
Output: 2011/10/04 10:46:11 func1(“Go”) = 7, EOF
Output: 2011/10/04 10:46:11 func1(“Go”) = 7, EOF
## 链接
- [目录](directory.md)
- 上一节:[传递变长参数](06.3.md)
- 下一节:[内置函数](06.5.md)