golang设置每天12点定时任务

package cron

import "time"

func StartTimer(F func()) {
	go func() {
		for {
			F()
			next := now.Add(time.Hour * 24)
			next = time.Date(next.Year(), next.Month(), next.Day(), 0, 0, 0, 0, next.Location())
			t := time.NewTimer(next.Sub(time.Now()))
			<-t.C
		}
	}()
}

你可能感兴趣的:(Golang)