如何获取 Goroutine 的运行时 ID?
我从导入的包中获取交错日志 - 一种方法是向每个 goroutine 的日志添加唯一标识符。
我找到了一些参考资料runtime.GoID:
func worker() {
id := runtime.GoID()
log.Println("Goroutine ID:", id)
}
Run Code Online (Sandbox Code Playgroud)
但看起来现在已经过时/已被删除 - https://pkg.go.dev/runtime?