package main import ( "fmt" "github.com/astaxie/beego/toolbox" "time" ) func task() error { fmt.Println(time.Now().Format("2006-01-02 15:04:05")) return nil } func main() { tk := toolbox.NewTask("task1", "0/5 * * * * 5", task) err := tk.Run() if err != nil{ fmt.Println(err) } toolbox.AddTask("task1", tk) toolbox.StartTask() time.Sleep(time.Minute * 5) toolbox.StopTask() }