GITLAB

Hermes / api-game

Sign in
  • Sign in
  • Project
  • Files
  • Commits
  • Network
  • Graphs
  • Issues 0
  • Merge Requests 0
  • Wiki
  • api-game_qianyi
  • util
  • zmisc
  • goroutine.go
  • 74e1d4d3   feat✨:配置管理 Browse Code »
    王家文
    2024-05-27 12:18:10 +0800  
goroutine.go 228 Bytes
Edit Raw Blame History
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
package zmisc

import (
	"fmt"
	"runtime"
)

// GetGoroutineID 获取携程ID
func GetGoroutineID() int {
	var buf [64]byte
	runtime.Stack(buf[:], false)
	var id int
	fmt.Sscanf(string(buf[:]), "goroutine %d", &id)
	return id
}