Go Trace
Q1:请使用 runtime/trace 包,写一个使用trace的例子 启动两个goroutine,记录trace func main() { f, err := os.Create("trace.out") if err != nil { log.Fatalf("failed to create trace file: %v", err) } defer f.Close() if err := trace.Start(f); err != nil { log.Fatalf("failed to start trace: %v", err) } defer trace.Stop() var wg sync.WaitGroup wg.Add(2) go wait(&wg) go sum(&wg) wg.Wait() } func wait(wg *sync.WaitGroup) { defer wg.Done() time.Sleep(2 * time.Second) } func sum(wg *sync.WaitGroup) { defer wg.Done() i, s := 0, 0 ch := time....