【文件属性】:
文件名称:Go定时器、单元测试
文件大小:23KB
文件格式:PDF
更新时间:2021-01-07 16:59:03
单元 单元测试 定时器
定时器
初始化和一般使用
t:=time.NewTicker(time.Second)
for v := range t.C {
fmt.Println(hello,v)
}
结果:一秒输出一次
一定时间后
time.After(time.Second)
select {
case v := <-ch1:
fmt.Println(v)
case v := <-ch2:
fmt.Println(v)
case <-time.After(time.Second):
fmt.Println(get data timeout)
}
关闭回收