Package cron provides functionality for generate signals at intervals timed in January 1, 1970 UTC. According to most cases, cron can work with gracefulexit.
package main
import (
"log"
"time"
"github.com/godump/cron"
"github.com/godump/gracefulexit"
)
func main() {
chanSpin := cron.Cron(time.Minute)
chanExit := gracefulexit.Chan()
done := 0
log.Println("main: loop")
for {
select {
case <-chanSpin:
log.Println(time.Now())
case <-chanExit:
done = 1
}
if done != 0 {
break
}
}
log.Println("main: done")
}