您的当前位置:首页正文

Golang trace分析

2024-11-29 来源:个人技术集锦

Gin加入trace接口

	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

显示全文