gitee.com/sy_183/go-common@v1.0.5-0.20231205030221-958cfe129b47/ipc/cgo/sem/test/main.go (about) 1 package main 2 3 import ( 4 "fmt" 5 semPkg "gitee.com/sy_183/go-common/ipc/cgo/sem" 6 ) 7 8 func main() { 9 var sem semPkg.Sem 10 if err := sem.Init(0, 2); err != nil { 11 panic(err) 12 } 13 fmt.Println(sem.GetValue()) 14 fmt.Println(sem.TryWait()) 15 fmt.Println(sem.TryWait()) 16 fmt.Println(sem.TryWait()) 17 fmt.Println(sem.TryWait()) 18 fmt.Println(sem.TryWait()) 19 fmt.Println(sem.TryWait()) 20 }