github.com/cocotyty/oneshot@v0.0.0-20210707064948-4d5a81d0b747/example/demo/main.go (about)

     1  package main
     2  
     3  import (
     4  	"github.com/cocotyty/oneshot"
     5  	"log"
     6  	"time"
     7  )
     8  
     9  func main() {
    10  	s := &oneshot.Shot{}
    11  	go func() {
    12  		time.Sleep(time.Second)
    13  		s.WakeUp()
    14  	}()
    15  	log.Println("wait")
    16  	s.Wait()
    17  	log.Println("finished")
    18  }