github.com/Rookout/GoSDK@v0.1.48/pkg/services/collection/go_id/go_id.go (about)

     1  package go_id
     2  
     3  import (
     4  	"unsafe"
     5  
     6  	"github.com/Rookout/GoSDK/pkg/services/go_runtime"
     7  )
     8  
     9  //go:nosplit
    10  func CurrentGoID() int {
    11  	g := go_runtime.Getg()
    12  	return GetGoID(g)
    13  }
    14  
    15  func GetGoID(g go_runtime.GPtr) int {
    16  	goidInG := g + goidOffsetInG
    17  	goid := *(*int64)(unsafe.Pointer(goidInG)) // goid is int64
    18  	return int(goid)
    19  }