From 0f246792b8808d684222072ebea8a6bb081c2e88 Mon Sep 17 00:00:00 2001 From: wangxin Date: Thu, 18 Nov 2021 21:26:54 +0800 Subject: [PATCH] fix: when remote watch fails, the callback should not be called --- viper.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/viper.go b/viper.go index 21a35b2..12ce22a 100644 --- a/viper.go +++ b/viper.go @@ -1903,7 +1903,9 @@ func (v *Viper) watchKeyValueConfigOnChannel(run func()) error { b := <-rc reader := bytes.NewReader(b.Value) v.unmarshalReader(reader, v.kvstore) - run() + if b.Error == nil { + run() + } } }(respc) return nil