github.com/iikira/iikira-go-utils@v0.0.0-20230610031953-f2cb11cde33a/utils/delay/delay.go (about)

     1  package delay
     2  
     3  import (
     4  	"time"
     5  )
     6  
     7  // NewDelayChan 发送延时信号
     8  func NewDelayChan(t time.Duration) <-chan struct{} {
     9  	c := make(chan struct{})
    10  	go func() {
    11  		time.Sleep(t)
    12  		close(c)
    13  	}()
    14  	return c
    15  }