package main import ( "fmt" "time" ) func task() { fmt.Println(time.Now().Local()) } func main() { task() t := time.NewTimer(time.Second * 5) for { select{ case <-t.C: t.Reset(time.Second * 5) task() } } }
package main import ( "fmt" "time" ) func task() { fmt.Println(time.Now().Local()) } func main() { t := time.NewTicker(3 * time.Second) for { select { case <-t.C: task() } } }