golang没有cpu的/debug/pprof/profile端点,同时拥有其他一切

golang没有cpu的/debug/pprof/profile端点,同时拥有其他一切,go,profiling,Go,Profiling,我对一个无法评测golang程序的问题感到非常困惑,我的所有其他端点都在/debug/pprof下,但没有用于CPU评测的/debug/pprof/profile 有没有人偶然发现过这样的问题 go tool pprof http://localhost:7778/debug/pprof/profile Fetching profile from http://localhost:7778/debug/pprof/profile Please wait... (30s) server respo

我对一个无法评测golang程序的问题感到非常困惑,我的所有其他端点都在/debug/pprof下,但没有用于CPU评测的/debug/pprof/profile 有没有人偶然发现过这样的问题

go tool pprof http://localhost:7778/debug/pprof/profile
Fetching profile from http://localhost:7778/debug/pprof/profile
Please wait... (30s)
server response: 404 Not Found

/debug/pprof/

profiles:
19  block
31  goroutine
10  heap
0   mutex
11  threadcreate

full goroutine stack dump
我以这种方式设置配置文件

r := http.NewServeMux()
r.Handle("/debug/pprof/", http.HandlerFunc(pprof.Index))
原因可能是什么

更新:运行

http.ListenAndServe("localhost:4444", nil)

(即启动默认http服务器)修复了我的自定义端点的问题

找到它时,我没有像在init中那样在此处注册所有处理程序

我遇到了与您相同的错误,我已根据文档进行了注册。如果有人遇到同样的问题,那么您需要添加
http.DefaultServeMux
,因此完整的行应该是:

参考是

  r := mux.NewRouter()

  r.PathPrefix("/debug/").Handler(http.DefaultServeMux)

  r.HandleFunc("/debug/pprof/", pprof.Index)
  r.HandleFunc("/debug/pprof/cmdline", pprof.Cmdline)
  r.HandleFunc("/debug/pprof/profile", pprof.Profile)
  r.HandleFunc("/debug/pprof/symbol", pprof.Symbol)
  r.HandleFunc("/debug/pprof/trace", pprof.Trace)