func CgoCallbackGC() { const P = 100 done := make(chan bool) // allocate a bunch of stack frames and spray them with pointers for i := 0; i < P; i++ { go func() { grow() done <- true }() } for i := 0; i < P; i++ { <-done } // now give these stack frames to cgo callbacks for i := 0; i < P; i++ { go func() { C.foo() done <- true }() } for i := 0; i < P; i++ { <-done } fmt.Printf("OK\n") }
func main() { runtime.GOMAXPROCS(runtime.NumCPU()) fmt.Println(C.GoString(C.foo())) }
func main() { // Don't report error for package "C". It's for Cgo. println(C.bar) println(C.foo()) }
func main() { fmt.Println(C.GoString(C.foo())) }
func main() { fmt.Println(C.count) C.foo() }
func CallCgo(n int) { for i := 0; i < n; i++ { C.foo() } }
func main() { fmt.Println("Go: main") C.registerIt(C.foo()) }
func main() { fmt.Println("From libfoo: ", C.foo()) }
func Bar() { C.foo() }