Skip to content

Instantly share code, notes, and snippets.

@huantt
Created April 25, 2023 14:44
Show Gist options
  • Save huantt/82f12eaa40a41d80fe3775dc0398b53e to your computer and use it in GitHub Desktop.
Save huantt/82f12eaa40a41d80fe3775dc0398b53e to your computer and use it in GitHub Desktop.
func GetGID() uint64 {
b := make([]byte, 64)
b = b[:runtime.Stack(b, false)]
b = bytes.TrimPrefix(b, []byte("goroutine "))
b = b[:bytes.IndexByte(b, ' ')]
n, _ := strconv.ParseUint(string(b), 10, 64)
return n
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment