From bf5f0baed749a5e295b59b1cd7ef8e63116720ad Mon Sep 17 00:00:00 2001 From: astaxie Date: Tue, 30 Jul 2013 15:23:14 +0800 Subject: [PATCH] only watch go file's modify --- watch.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/watch.go b/watch.go index 98430d2..48881b3 100644 --- a/watch.go +++ b/watch.go @@ -33,6 +33,9 @@ func NewWatcher(paths []string) { if checkTMPFile(e.Name) { continue } + if !checkIsGoFile(e.Name) { + continue + } if t, ok := eventTime[e.Name]; ok { // if 500ms change many times, then ignore it. @@ -135,3 +138,11 @@ func checkTMPFile(name string) bool { } return false } + +// checkIsGoFile return true if the name is HasSuffix go +func checkIsGoFile(name string) bool { + if strings.HasSuffix(name, ".go") { + return true + } + return false +}