app.GET("/trace", func(c *gin.Context) {
second, err := strconv.ParseInt(c.Query("seconds"), 10, 64)
f, err := os.OpenFile("trace.out", os.O_RDWR|os.O_CREATE, 0644)
if err != nil {
c.String(http.StatusOK, err.Error())
return
}
trace.Start(f)
time.Sleep(time.Duration(second) * time.Second)
trace.Stop()
f.Close()
})
https://www.bookstack.cn/read/qcrao-Go-Questions/spilt.14.GC-GC.md