go用来指定睡眠时间的函数为time.Sleep,接口为:
// Sleep pauses the current goroutine for at least the duration d.
// A negative or zero duration causes Sleep to return immediately.
func Sleep(d Duration)
传入的为一个Duration,所以如果想睡眠5s钟,不能直接…
Golang time after典型用法
time after触发,例子:
package main
import ("fmt""time"
)
func main() {fmt.Println("Start Time ", time.Now())a : time.After(5*time.Second)fmt.Println(<-a)fmt.Println("End…