Skip to content

Instantly share code, notes, and snippets.

@dt665m
Created January 29, 2018 03:31
Show Gist options
  • Save dt665m/43090d8c3a68b6532f8b81c6ca261346 to your computer and use it in GitHub Desktop.
Save dt665m/43090d8c3a68b6532f8b81c6ca261346 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"time"
)
func doEvery(d time.Duration, f func(time.Time)) {
for x := range time.Tick(d) {
f(x)
}
}
func main() {
doEvery(20*time.Millisecond, func(t time.Time) {
fmt.Println("hello world at: ", t)
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment