From 104f9d07714e471ea993bb42bbbcbf081c0c4abb Mon Sep 17 00:00:00 2001 From: yejiangming <1600012895@pku.edu.cn> Date: Wed, 25 May 2022 22:33:47 +0800 Subject: [PATCH] fix watchKeyValueConfigOnChannel panic when remote config update --- viper.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/viper.go b/viper.go index 4a9dac9..35ae2e4 100644 --- a/viper.go +++ b/viper.go @@ -1882,7 +1882,9 @@ func (v *Viper) watchKeyValueConfigOnChannel() error { for { b := <-rc reader := bytes.NewReader(b.Value) - v.unmarshalReader(reader, v.kvstore) + kvstore := make(map[string]interface{}) + v.unmarshalReader(reader, kvstore) + v.kvstore = kvstore } }(respc) return nil