1
0
mirror of https://github.com/chai2010/advanced-go-programming-book.git synced 2025-05-24 04:22:22 +00:00
2019-08-05 11:06:38 +08:00

35 lines
452 B
Go

package main
import (
"reflect"
"time"
)
func getg() interface{}
type eface struct {
_type, elem uintptr
}
//go:nosplit
func runtime_convT2E_hack(_type, elem uintptr) eface {
return eface{
_type: _type,
elem: elem,
}
}
func GetGoid() int64 {
g := getg()
goid := reflect.ValueOf(g).FieldByName("goid").Int()
return goid
}
func main() {
println("a:", GetGoid())
go func() {
println("b:", GetGoid())
}()
time.Sleep(time.Second)
}