github.com/egonelbre/exp@v0.0.0-20240430123955-ed1d3aa93911/sync2/runtime2/goid.go (about)

     1  package runtime2
     2  
     3  import (
     4  	"bytes"
     5  	"runtime"
     6  	"strconv"
     7  )
     8  
     9  func GOID() int64
    10  func g() uintptr
    11  
    12  func goidslow() int64 {
    13  	b := make([]byte, 64)
    14  	b = b[:runtime.Stack(b, false)]
    15  	b = bytes.TrimPrefix(b, []byte("goroutine "))
    16  	b = b[:bytes.IndexByte(b, ' ')]
    17  	n, _ := strconv.ParseInt(string(b), 10, 64)
    18  	return n
    19  }