Skip to content

Instantly share code, notes, and snippets.

@sayden
Last active August 17, 2018 21:07
Show Gist options
  • Save sayden/c2328c18a40d8f7d6ef7ae32efcce484 to your computer and use it in GitHub Desktop.
Save sayden/c2328c18a40d8f7d6ef7ae32efcce484 to your computer and use it in GitHub Desktop.
timeAfter
package time_profile
import "time"
func timeAfter() chan struct{} {
ch := make(chan struct{})
go timeAfterGoroutine(ch)
return ch
}
func timeAfterGoroutine(ch chan struct{}) {
waitduration := 5000 * time.Millisecond
rand.Seed(33)
for {
select {
case _ = <-ch:
case <-time.After(waitduration):
}
}
log.Info("Finished")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment