From c1a2a2448cbbca8bd267e8f8b6b629b72737960d Mon Sep 17 00:00:00 2001 From: JJ Brown Date: Mon, 24 Jan 2022 08:58:34 -0600 Subject: [PATCH] Updated to use the new fsnotify This introduces a lot of bugfixes in that tool in the last 5 years! --- go.mod | 2 +- go.sum | 6 ++++-- gowatch.go | 8 ++++---- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/go.mod b/go.mod index 89e120c..d6d3b32 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/silenceper/gowatch go 1.14 require ( - github.com/howeyc/fsnotify v0.9.0 + github.com/fsnotify/fsnotify v1.5.1 github.com/mitchellh/go-ps v1.0.0 github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect github.com/silenceper/log v0.0.0-20171204144354-e5ac7fa8a76a diff --git a/go.sum b/go.sum index 46a1851..862ec70 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -github.com/howeyc/fsnotify v0.9.0 h1:0gtV5JmOKH4A8SsFxG2BczSeXWWPvcMT0euZt5gDAxY= -github.com/howeyc/fsnotify v0.9.0/go.mod h1:41HzSPxBGeFRQKEEwgh49TRw/nKBsYZ2cF1OzPjSJsA= +github.com/fsnotify/fsnotify v1.5.1 h1:mZcQUHVQUQWoPXXtuf9yuEXKudkV2sx1E06UadKWpgI= +github.com/fsnotify/fsnotify v1.5.1/go.mod h1:T3375wBYaZdLLcVNkcVbzGHY7f1l/uK5T5Ai1i3InKU= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= @@ -9,6 +9,8 @@ github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWb github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/silenceper/log v0.0.0-20171204144354-e5ac7fa8a76a h1:COf2KvPmardI1M8p2fhHsXlFS2EXSQygbGgcDYBI9Wc= github.com/silenceper/log v0.0.0-20171204144354-e5ac7fa8a76a/go.mod h1:nyN/YUSK3CgJjtNzm6dVTkcou+RYXNMP+XLSlzQu0m0= +golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c h1:F1jZWGFhYfh0Ci55sIpILtKKK8p3i2/krTr0H1rg74I= +golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU= gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v1 v1.0.0-20140924161607-9f9df34309c0 h1:POO/ycCATvegFmVuPpQzZFJ+pGZeX22Ufu6fibxDVjU= diff --git a/gowatch.go b/gowatch.go index af89638..4e154c2 100644 --- a/gowatch.go +++ b/gowatch.go @@ -11,7 +11,7 @@ import ( "strings" "time" - "github.com/howeyc/fsnotify" + "github.com/fsnotify/fsnotify" "github.com/mitchellh/go-ps" "github.com/silenceper/log" ) @@ -33,7 +33,7 @@ func NewWatcher(paths []string, files []string) { go func() { for { select { - case e := <-watcher.Event: + case e := <-watcher.Events: isbuild := true // Skip ignored files @@ -66,7 +66,7 @@ func NewWatcher(paths []string, files []string) { Autobuild(files) }() } - case err := <-watcher.Error: + case err := <-watcher.Errors: log.Errorf("%v", err) log.Warnf(" %s\n", err.Error()) // No need to exit here } @@ -76,7 +76,7 @@ func NewWatcher(paths []string, files []string) { log.Infof("Initializing watcher...\n") for _, path := range paths { log.Infof("Directory( %s )\n", path) - err = watcher.Watch(path) + err = watcher.Add(path) if err != nil { log.Errorf("Fail to watch directory[ %s ]\n", err) os.Exit(2)