<span style="white-space:pre"> </span>//执行一次
<span style="white-space:pre"> </span>time.AfterFunc(5*time.Second, func() { log.Println("expired") })
<span style="white-space:pre"> </span><pre name="code" class="plain"><span style="white-space:pre"> </span>//反复执行timer := time.NewTicker(5 * time.Second)for {select {case <-timer.C:go func() {log.Println(time.Now())}()}}
有疑问加站长微信联系(非本文作者)