From b80be0b847fc216498643429e3bcc7a685bc454c Mon Sep 17 00:00:00 2001 From: Jeff DeFond Date: Fri, 13 Jan 2017 12:28:45 -0800 Subject: [PATCH] Add check to see if v.onConfigChange is nil before calling --- viper.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/viper.go b/viper.go index 2603c78..1bc46f5 100644 --- a/viper.go +++ b/viper.go @@ -262,7 +262,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: