From 46a6809372d39e892b9059862864dffced914472 Mon Sep 17 00:00:00 2001 From: Reza Mohammadi Date: Mon, 21 Nov 2016 17:55:21 +0330 Subject: [PATCH] Move onConfigChangeList initialize to New Closes #175 --- viper.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/viper.go b/viper.go index 2eba734..fca0294 100644 --- a/viper.go +++ b/viper.go @@ -173,6 +173,7 @@ func New() *Viper { v.env = make(map[string]string) v.aliases = make(map[string]string) v.typeByDefValue = false + v.onConfigChangeList = make([]func(fsnotify.Event), 0) return v } @@ -231,9 +232,6 @@ func OnConfigChange(run func(in fsnotify.Event)) { v.OnConfigChange(run) } // OnConfigChange adds a change listener to the list of current listeners func (v *Viper) OnConfigChange(run func(in fsnotify.Event)) { - if v.onConfigChangeList == nil { - v.onConfigChangeList = make([]func(fsnotify.Event), 0, 1) - } v.onConfigChangeList = append(v.onConfigChangeList, run) }