Update viper.go

This commit is contained in:
Márk Sági-Kazár 2023-01-19 16:24:08 +01:00 committed by GitHub
parent 3b18b32fd3
commit 6c4d359745
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -421,18 +421,16 @@ var SupportedExts = []string{"json", "toml", "yaml", "yml", "properties", "props
// SupportedRemoteProviders are universally supported remote providers. // SupportedRemoteProviders are universally supported remote providers.
var SupportedRemoteProviders = []string{"etcd", "etcd3", "consul", "firestore"} var SupportedRemoteProviders = []string{"etcd", "etcd3", "consul", "firestore"}
// OnConfigChange is used to implement a response on config files change. // OnConfigChange sets the event handler that is called when a config file changes.
func OnConfigChange(run func(in fsnotify.Event)) { v.OnConfigChange(run) } func OnConfigChange(run func(in fsnotify.Event)) { v.OnConfigChange(run) }
func (v *Viper) OnConfigChange(run func(in fsnotify.Event)) { func (v *Viper) OnConfigChange(run func(in fsnotify.Event)) {
v.onConfigChange = run v.onConfigChange = run
} }
// WatchConfig is watching changes on config files // WatchConfig starts watching a config file for changes.
// to start event in OnConfigChange. Used for global viper config.
func WatchConfig() { v.WatchConfig() } func WatchConfig() { v.WatchConfig() }
// WatchConfig is watching changes on config files // WatchConfig starts watching a config file for changes.
// to start event in OnConfigChange.
func (v *Viper) WatchConfig() { func (v *Viper) WatchConfig() {
initWG := sync.WaitGroup{} initWG := sync.WaitGroup{}
initWG.Add(1) initWG.Add(1)