|
|
@ -174,9 +174,16 @@ func (s *iniConfigSection) ChildSections() (sections []ConfigSection) { |
|
|
|
return sections |
|
|
|
return sections |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func configProviderLoadOptions() ini.LoadOptions { |
|
|
|
|
|
|
|
return ini.LoadOptions{ |
|
|
|
|
|
|
|
KeyValueDelimiterOnWrite: " = ", |
|
|
|
|
|
|
|
IgnoreContinuation: true, |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// NewConfigProviderFromData this function is mainly for testing purpose
|
|
|
|
// NewConfigProviderFromData this function is mainly for testing purpose
|
|
|
|
func NewConfigProviderFromData(configContent string) (ConfigProvider, error) { |
|
|
|
func NewConfigProviderFromData(configContent string) (ConfigProvider, error) { |
|
|
|
cfg, err := ini.Load(strings.NewReader(configContent)) |
|
|
|
cfg, err := ini.LoadSources(configProviderLoadOptions(), strings.NewReader(configContent)) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
} |
|
|
@ -190,7 +197,7 @@ func NewConfigProviderFromData(configContent string) (ConfigProvider, error) { |
|
|
|
// NewConfigProviderFromFile load configuration from file.
|
|
|
|
// NewConfigProviderFromFile load configuration from file.
|
|
|
|
// NOTE: do not print any log except error.
|
|
|
|
// NOTE: do not print any log except error.
|
|
|
|
func NewConfigProviderFromFile(file string, extraConfigs ...string) (ConfigProvider, error) { |
|
|
|
func NewConfigProviderFromFile(file string, extraConfigs ...string) (ConfigProvider, error) { |
|
|
|
cfg := ini.Empty(ini.LoadOptions{KeyValueDelimiterOnWrite: " = "}) |
|
|
|
cfg := ini.Empty(configProviderLoadOptions()) |
|
|
|
loadedFromEmpty := true |
|
|
|
loadedFromEmpty := true |
|
|
|
|
|
|
|
|
|
|
|
if file != "" { |
|
|
|
if file != "" { |
|
|
@ -339,6 +346,7 @@ func NewConfigProviderForLocale(source any, others ...any) (ConfigProvider, erro |
|
|
|
iniFile, err := ini.LoadSources(ini.LoadOptions{ |
|
|
|
iniFile, err := ini.LoadSources(ini.LoadOptions{ |
|
|
|
IgnoreInlineComment: true, |
|
|
|
IgnoreInlineComment: true, |
|
|
|
UnescapeValueCommentSymbols: true, |
|
|
|
UnescapeValueCommentSymbols: true, |
|
|
|
|
|
|
|
IgnoreContinuation: true, |
|
|
|
}, source, others...) |
|
|
|
}, source, others...) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
return nil, fmt.Errorf("unable to load locale ini: %w", err) |
|
|
|
return nil, fmt.Errorf("unable to load locale ini: %w", err) |
|
|
|