diff --git a/config.go b/config.go index c069349..379799f 100644 --- a/config.go +++ b/config.go @@ -67,9 +67,7 @@ func init() { func loadAndwatchCfgFile(filename string) { provider := file.Provider(filename) - if cfgError := k.Load(provider, toml.Parser()); cfgError != nil { - log.Warn().Msg(fmt.Sprintf("Error while trying to read %s: %s\n", filename, cfgError.Error())) - } + loadCfg(provider) // Watch for changes and reload when detected provider.Watch(func(_ interface{}, err error) { @@ -77,12 +75,20 @@ func loadAndwatchCfgFile(filename string) { return } - if cfgError := k.Load(provider, toml.Parser()); cfgError != nil { - log.Warn().Msg(fmt.Sprintf("Error while trying to read %s: %s\n", filename, cfgError.Error())) - } + loadCfg(provider) }) } +func loadCfg(provider *file.File) { + fmt.Println("%#v\n", provider) // &file.File{path:"/etc/itd.toml"} + filename := "" + filename = provider.path // provider.path undefined (type *file.File has no field or method path) + filename = (*provider).path // (*provider).path undefined (type file.File has no field or method path) + if cfgError := k.Load(provider, toml.Parser()); cfgError != nil { + log.Warn().Msg(fmt.Sprintf("Error while trying to read %s: %s\n", filename, cfgError.Error())) + } +} + func setCfgDefaults() { k.Load(confmap.Provider(map[string]interface{}{ "bluetooth.adapter": "hci0",