Go——cron定时任务Demo
生活随笔
收集整理的這篇文章主要介紹了
Go——cron定时任务Demo
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
源代碼:https://gitee.com/shentuzhigang/mini-project/blob/master/cron_demo
官方文檔
https://pkg.go.dev/github.com/robfig/cron
Demo
package cron_demoimport ("fmt""github.com/robfig/cron/v3""testing""time" )func TestCron(t *testing.T) {c := cron.New()c.Start()entryID, err := c.AddFunc("*/1 * * * *", func() {fmt.Println(time.Now())})if err != nil {fmt.Println(entryID)return}select {} }參考文章
總結
以上是生活随笔為你收集整理的Go——cron定时任务Demo的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Go——Artifactory的AQL查
- 下一篇: Iris——整合Gorm持久化的Casb