1
2
3
4
5 package main
6
7 import (
8 "syscall"
9 _ "testcshared/p"
10 "time"
11 )
12
13 import "C"
14
15 var initCh = make(chan int, 1)
16 var ranMain bool
17
18 func init() {
19
20 time.Sleep(100 * time.Millisecond)
21 initCh <- 42
22 }
23
24 func main() {
25 ranMain = true
26 }
27
28
29 func DidInitRun() bool {
30 select {
31 case x := <-initCh:
32 if x != 42 {
33
34 println("want init value of 42, got: ", x)
35 syscall.Exit(2)
36 }
37 return true
38 default:
39 return false
40 }
41 }
42
43
44 func DidMainRun() bool {
45 return ranMain
46 }
47
View as plain text