dslfq06464 2017-11-10 19:36 采纳率: 0%
浏览 400
已采纳

尝试使用Go工具跟踪解析跟踪时出错

I was following tutorial from JustForFunc episode 22

Added those two lines at the start of main() in main.go:

trace.Start(os.Stdout)
defer trace.Stop()

build the binary using go build -o appName

Timed it with time ./appName > m.trace

And finally tried to open trace with go tool trace m.trace but got following error:

2017/11/10 19:15:38 Parsing trace...
failed to parse trace: unknown event type 50 at offset 0x16

Little more background on my code(golang 1.9, linux) : it is a server for GET requests built with gin-gonic. I added extra line of code time.AfterFunc(20*time.Seconds, func(){closeServer()}) to close my server after 20 seconds so I could make few request to it and then stop server exiting program.

  • 写回答

1条回答 默认 最新

  • dongzuo4666 2017-11-11 12:02
    关注

    I found a solution to my problem. I followed this tutorial https://making.pusher.com/go-tool-trace/. Added code to main :

    f, err := os.Create("trace.out")
    if err != nil {
        panic(err)
    }
    defer f.Close()
    
    err = trace.Start(f)
    if err != nil {
        panic(err)
    }
    defer trace.Stop()
    // Your program here
    

    And it seems to be working fine. I have no idea what could cause this problem :(

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥35 平滑拟合曲线该如何生成
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 自己瞎改改,结果现在又运行不了了
  • ¥15 链式存储应该如何解决
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站