github.com/fzfile/BaiduPCS-Go@v0.0.0-20200606205115-4408961cf336/pcsutil/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  }