多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
[TOC] ## code <details> <summary>pprof.go</summary> ``` package utils import ( "log" "net/http" "net/http/pprof" ) func init() { http.DefaultServeMux = http.NewServeMux() } func Handle(mux *http.ServeMux) { mux.HandleFunc("/debug/pprof/", pprof.Index) mux.HandleFunc("/debug/pprof/cmdline", pprof.Cmdline) mux.HandleFunc("/debug/pprof/profile", pprof.Profile) mux.HandleFunc("/debug/pprof/symbol", pprof.Symbol) mux.HandleFunc("/debug/pprof/trace", pprof.Trace) } func NewServeMux() *http.ServeMux { mux := http.NewServeMux() Handle(mux) return mux } func NewServer(addr string) *http.Server { return &http.Server{ Addr: addr, Handler: NewServeMux(), } } func ListenAndServe(addr string) error { return NewServer(addr).ListenAndServe() } // 调用 RunPprof(":6061") func RunPprof(addr string) { go func() { log.Fatal(ListenAndServe(addr)) }() } ``` </details> <br/>