Go

pprof

import (
	"net/http"
	_ "net/http/pprof"

	"github.com/felixge/fgprof"
)

func main() {
	http.DefaultServeMux.Handle("/debug/fgprof", fgprof.Handler())
	go func() {
    perfPort := 6060
		fmt.Println(http.ListenAndServe(fmt.Sprintf("127.0.0.1:%d", perfPort), nil))
	}()
}
go tool pprof --http=127.0.0.1:6061 'http://127.0.0.1:6060/debug/fgprof?seconds=60'
go tool pprof --http=127.0.0.1:6061 'http://127.0.0.1:6060/debug/pprof/profile?seconds=5'
go tool pprof --http=127.0.0.1:6061 'http://127.0.0.1:6060/debug/pprof/heap?seconds=5'

goroutine 数とスタックトレース

curl -s 'http://127.0.0.1:6060/debug/pprof/goroutine?debug=1'

ref

update go version

go mod edit -go=1.22.5
go mod tidy

reset cache

go clean --modcache
最終更新日