From 464cdab72ae3e0c4e6b3c1cb01065e3e06398325 Mon Sep 17 00:00:00 2001 From: Mark Sagi-Kazar Date: Wed, 29 Nov 2023 17:59:13 +0100 Subject: [PATCH] refactor: drop fsonitfy wrapper Signed-off-by: Mark Sagi-Kazar --- viper.go | 2 +- watch.go | 11 ----------- watch_unsupported.go | 31 ------------------------------- 3 files changed, 1 insertion(+), 43 deletions(-) delete mode 100644 watch.go delete mode 100644 watch_unsupported.go diff --git a/viper.go b/viper.go index c1eab71..bc63153 100644 --- a/viper.go +++ b/viper.go @@ -439,7 +439,7 @@ func (v *Viper) WatchConfig() { initWG := sync.WaitGroup{} initWG.Add(1) go func() { - watcher, err := newWatcher() + watcher, err := fsnotify.NewWatcher() if err != nil { v.logger.Error(fmt.Sprintf("failed to create watcher: %s", err)) os.Exit(1) diff --git a/watch.go b/watch.go deleted file mode 100644 index e98fce8..0000000 --- a/watch.go +++ /dev/null @@ -1,11 +0,0 @@ -//go:build darwin || dragonfly || freebsd || openbsd || linux || netbsd || solaris || windows - -package viper - -import "github.com/fsnotify/fsnotify" - -type watcher = fsnotify.Watcher - -func newWatcher() (*watcher, error) { - return fsnotify.NewWatcher() -} diff --git a/watch_unsupported.go b/watch_unsupported.go deleted file mode 100644 index 7076405..0000000 --- a/watch_unsupported.go +++ /dev/null @@ -1,31 +0,0 @@ -//go:build appengine || (!darwin && !dragonfly && !freebsd && !openbsd && !linux && !netbsd && !solaris && !windows) - -package viper - -import ( - "fmt" - "runtime" - - "github.com/fsnotify/fsnotify" -) - -func newWatcher() (*watcher, error) { - return &watcher{}, fmt.Errorf("fsnotify not supported on %s", runtime.GOOS) -} - -type watcher struct { - Events chan fsnotify.Event - Errors chan error -} - -func (*watcher) Close() error { - return nil -} - -func (*watcher) Add(name string) error { - return nil -} - -func (*watcher) Remove(name string) error { - return nil -}