From 1bcb21f86fe60d75bfa6a0c3667b97fc5d35a377 Mon Sep 17 00:00:00 2001 From: Mark Sagi-Kazar Date: Thu, 3 Nov 2022 17:57:32 +0100 Subject: [PATCH] refactor: use new Has fsnotify method for event matching Signed-off-by: Mark Sagi-Kazar --- viper.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/viper.go b/viper.go index 84c600fcb..d8ad03f7c 100644 --- a/viper.go +++ b/viper.go @@ -463,9 +463,8 @@ func (v *Viper) WatchConfig() { // we only care about the config file with the following cases: // 1 - if the config file was modified or created // 2 - if the real path to the config file changed (eg: k8s ConfigMap replacement) - const writeOrCreateMask = fsnotify.Write | fsnotify.Create if (filepath.Clean(event.Name) == configFile && - event.Op&writeOrCreateMask != 0) || + (event.Has(fsnotify.Write) || event.Has(fsnotify.Create))) || (currentConfigFile != "" && currentConfigFile != realConfigFile) { realConfigFile = currentConfigFile err := v.ReadInConfig() @@ -475,8 +474,7 @@ func (v *Viper) WatchConfig() { if v.onConfigChange != nil { v.onConfigChange(event) } - } else if filepath.Clean(event.Name) == configFile && - event.Op&fsnotify.Remove != 0 { + } else if filepath.Clean(event.Name) == configFile && event.Has(fsnotify.Remove) { eventsWG.Done() return }