1// Copyright 2015 The Go Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style 3// license that can be found in the LICENSE file. 4 5package main 6 7import ( 8 "syscall" 9 _ "testcshared/p" 10 "time" 11) 12 13import "C" 14 15var initCh = make(chan int, 1) 16var ranMain bool 17 18func init() { 19 // emulate an exceedingly slow package initialization function 20 time.Sleep(100 * time.Millisecond) 21 initCh <- 42 22} 23 24func main() { 25 ranMain = true 26} 27 28//export DidInitRun 29func DidInitRun() bool { 30 select { 31 case x := <-initCh: 32 if x != 42 { 33 // Just in case initCh was not correctly made. 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//export DidMainRun 44func DidMainRun() bool { 45 return ranMain 46} 47