Created
March 15, 2013 20:43
-
-
Save kisielk/5172973 to your computer and use it in GitHub Desktop.
Timer, why u no fire?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var ( | |
Forever = time.Duration(math.MaxInt64) | |
Debounce = time.Second | |
) | |
// Other unrelated things here | |
for { | |
t := time.NewTimer(Forever) | |
select { | |
case event := <-watcher.Event: | |
if event.IsCreate() && strings.HasSuffix(event.Name, ".go") { | |
watcher.Watch(event.Name) | |
} | |
// We don't watch IsDelete() right now because editors like to do weird things | |
log.Println(event) | |
log.Println("timer reset", t.Reset(Debounce)) | |
case <-t.C: | |
log.Println("timer expired", t.Reset(Forever)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment