func PeriodicRoutine(period int, f func()) {
ticker := time.NewTicker(time.Second * time.Duration(period))
go func() {
defer func() {
if p := recover(); p != nil {
beego.Error(fmt.Sprintf("Recovered panic: %s", p))
}
}()
for range ticker.C {
f()
}
}()
}
golang 周期性执行
最新推荐文章于 2022-11-14 19:25:22 发布