安装go-torch go get github.com/uber/go-torch 安装 FlameGraph cd $WORK_PATH && git clone https://github.com/brendangregg/FlameGraph.git export PATH=$PATH:$WORK_PATH/FlameGraph-master 安装graphviz yum install graphviz(CentOS, Redhat) package main
import ( “net/http” “net/http/pprof” )
func main() { // 主函数中添加 go func() { http.HandleFunc(“/debug/pprof/block”, pprof.Index) http.HandleFunc(“/debug/pprof/goroutine”, pprof.Index) http.HandleFunc(“/debug/pprof/heap”, pprof.Index) http.HandleFunc(“/debug/pprof/threadcreate”, pprof.Index)
http.ListenAndServe("0.0.0.0:8888", nil)
}()
var finishWaiter chan int
<-finishWaiter }