合规国际互联网加速 OSASE为企业客户提供高速稳定SD-WAN国际加速解决方案。 广告
[TOC] ## 实例 ``` func Example() { f, err := os.Create("trace.out") if err != nil { log.Fatalf("failed to create trace output file: %v", err) } defer func() { if err := f.Close(); err != nil { log.Fatalf("failed to close trace file: %v", err) } }() if err := trace.Start(f); err != nil { log.Fatalf("failed to start trace: %v", err) } defer trace.Stop() // your program here RunMyProgram() } func RunMyProgram() { fmt.Printf("this function will be traced") } ``` 执行 ``` go test -trace=trace.out ```