From 1336a0e4ab497e2d61412e3eb7b76dfa5f8c32b6 Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar Date: Mon, 27 May 2013 15:41:33 -0700 Subject: [PATCH] remove a redundant goroutine --- watch.go | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/watch.go b/watch.go index 35fc923..dc0b6ef 100644 --- a/watch.go +++ b/watch.go @@ -120,10 +120,10 @@ func (fw *PollingFileWatcher) ChangeEvents(origFi os.FileInfo) chan bool { ch := make(chan bool) stop := make(chan bool) var once sync.Once - every2Seconds := time.Tick(2 * time.Second) var prevModTime time.Time - // XXX: use tomb.Tomb to cleanly managed these goroutines. + // XXX: use tomb.Tomb to cleanly manage these goroutines. replace + // the panic (below) with tomb's Kill. stopAndClose := func() { go func() { @@ -169,19 +169,6 @@ func (fw *PollingFileWatcher) ChangeEvents(origFi os.FileInfo) chan bool { } }() - go func() { - for { - select { - case <-every2Seconds: - // XXX: not using file descriptor as per contract. - if _, err := os.Stat(fw.Filename); os.IsNotExist(err) { - once.Do(stopAndClose) - return - } - } - } - }() - return ch }