From e919dff7ac6fdb067d55defa3bb4ff3912c47fc1 Mon Sep 17 00:00:00 2001 From: Andrew Odintsov Date: Wed, 16 May 2018 14:22:57 +0300 Subject: [PATCH] call onConfigChange callback only if it is not nil, so i really become an optional parameter. --- viper.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/viper.go b/viper.go index 907a102..7c4e0c2 100644 --- a/viper.go +++ b/viper.go @@ -289,7 +289,9 @@ func (v *Viper) WatchConfig() { if err != nil { log.Println("error:", err) } - v.onConfigChange(event) + if v.onConfigChange != nil { + v.onConfigChange(event) + } } } case err := <-watcher.Errors: