From 518241257478c557633ab36e474dfcaeb9a3c623 Mon Sep 17 00:00:00 2001 From: glebik000 <58261400+glebik000@users.noreply.github.com> Date: Fri, 20 Jan 2023 01:38:18 +1000 Subject: [PATCH] Add DocBlock to WatchConfig (#1467) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add DocBlock to WatchConfig Added a small description of the WatchConfig(). So that you can understand in the ide why you could use it. * Update viper.go * update viper.go Signed-off-by: Mark Sagi-Kazar Signed-off-by: Mark Sagi-Kazar Co-authored-by: Márk Sági-Kazár Co-authored-by: Mark Sagi-Kazar --- viper.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/viper.go b/viper.go index 5c12529..06610fc 100644 --- a/viper.go +++ b/viper.go @@ -421,13 +421,18 @@ var SupportedExts = []string{"json", "toml", "yaml", "yml", "properties", "props // SupportedRemoteProviders are universally supported remote providers. var SupportedRemoteProviders = []string{"etcd", "etcd3", "consul", "firestore"} +// OnConfigChange sets the event handler that is called when a config file changes. func OnConfigChange(run func(in fsnotify.Event)) { v.OnConfigChange(run) } + +// OnConfigChange sets the event handler that is called when a config file changes. func (v *Viper) OnConfigChange(run func(in fsnotify.Event)) { v.onConfigChange = run } +// WatchConfig starts watching a config file for changes. func WatchConfig() { v.WatchConfig() } +// WatchConfig starts watching a config file for changes. func (v *Viper) WatchConfig() { initWG := sync.WaitGroup{} initWG.Add(1)