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