Skip to content

Instantly share code, notes, and snippets.

@sayden
Created August 17, 2018 21:11
Show Gist options
  • Save sayden/4660f76d0147ce88fce1a8ce866d1c9d to your computer and use it in GitHub Desktop.
Save sayden/4660f76d0147ce88fce1a8ce866d1c9d to your computer and use it in GitHub Desktop.
timer
package time_profile
import "time"
func newTimer() chan struct{} {
ch := make(chan struct{})
go func(ch chan struct{}) {
waitduration := 5000 * time.Millisecond
timer := time.NewTimer(waitduration)
for {
select {
case _ = <-ch:
case <-timer.C:
}
timer.Reset(waitduration)
}
log.Info("Finished")
}(ch)
return ch
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment