From dcb7f30f39751d61fe3a6c6d0568973736042e65 Mon Sep 17 00:00:00 2001 From: Mark Sagi-Kazar Date: Thu, 3 Nov 2022 20:21:21 +0100 Subject: [PATCH] feat: fix compilation for all platforms unsupported by fsnotify Signed-off-by: Mark Sagi-Kazar --- watch.go | 4 ++-- watch_disabled.go | 15 ++++++++------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/watch.go b/watch.go index 3a2fe8c..1ce84ea 100644 --- a/watch.go +++ b/watch.go @@ -1,5 +1,5 @@ -//go:build !js && !aix -// +build !js,!aix +//go:build darwin || dragonfly || freebsd || openbsd || linux || netbsd || solaris || windows +// +build darwin dragonfly freebsd openbsd linux netbsd solaris windows package viper diff --git a/watch_disabled.go b/watch_disabled.go index deebb0e..dbf74ef 100644 --- a/watch_disabled.go +++ b/watch_disabled.go @@ -1,14 +1,19 @@ -//go:build js || aix -// +build js aix +//go:build !darwin && !dragonfly && !freebsd && !openbsd && !linux && !netbsd && !solaris && !windows +// +build !darwin,!dragonfly,!freebsd,!openbsd,!linux,!netbsd,!solaris,!windows package viper import ( - "errors" + "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 @@ -25,7 +30,3 @@ func (*watcher) Add(name string) error { func (*watcher) Remove(name string) error { return nil } - -func newWatcher() (*watcher, error) { - return &watcher{}, errors.New("fsnotify is not supported on WASM") -}