func main() { runtime.LockOSThread() C.setVal(1) c := make(chan bool) go func() { runtime.LockOSThread() C.setVal(2) c <- true }() <-c if v := C.getVal(); v != 2 { panic(v) } }
//export GoRun func GoRun() { runtime.LockOSThread() c := make(chan bool) go func() { runtime.LockOSThread() C.setVal(2) c <- true }() <-c }