dongzi1959 2018-01-17 17:41
浏览 518
已采纳

通过HTTP运行时,pprof无法找到源文件

I am running remote profiling of my golang application on a remote server using "net/http/pprof".
I have set PPROF_BINARY_PATH env variable for go tool to be able to find my the local binary on my machine.
When I use the "list" keyword in the go tool pprof cli - I get a "no such file or directory" when the go tool is looking for the .go source files.

Error: open /go/src/github.com/foo/bar/baz.go: no such file or directory

it looks like it is looking for the source files in the remote machine's GOPATH which is "/go/" while on my personal machine it is in my home directory so that file is in .

/Users/myuser/go/src/github.com/foo/bar/baz.go

When I copied the desired source code file outside my GOPATH and to the directory the go tool is searching for - the "list" keyword works as expected but this is of course not optimal.

  • 写回答

1条回答 默认 最新

  • duanbigan7765 2018-10-19 10:27
    关注
    menghan@gram:/opt$ go tool pprof --help 2>&1 | grep source_path
        -source_path     Search path for source files
    

    Option --source_path may help.

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

报告相同问题?