21 lines
351 B
Go
21 lines
351 B
Go
package tasks
|
|
|
|
import (
|
|
"github.com/go-co-op/gocron"
|
|
"log"
|
|
"time"
|
|
)
|
|
|
|
var Scheduler *gocron.Scheduler
|
|
|
|
// StartScheduled
|
|
// @description: 启动定时任务
|
|
func StartScheduled() {
|
|
// 定时任务发送消息
|
|
Scheduler = gocron.NewScheduler(time.Local)
|
|
|
|
// 开启定时任务
|
|
Scheduler.StartAsync()
|
|
log.Println("定时任务初始化成功")
|
|
}
|