func newConfig() *config { return &config{ ConfigFile: conf.NewConfigFile(), Defaults: conf.NewConfigFile(), Overrides: conf.NewConfigFile(), } }
func (config *config) load() (err error) { if config.HasPath() { config.ConfigFile, err = conf.ReadConfigFile(config.Path()) if err != nil { return } } else { config.ConfigFile = conf.NewConfigFile() } if config.HasDefaultPath() { // Load defaults if a path was given. config.Defaults, err = conf.ReadConfigFile(config.DefaultPath()) if err != nil { return } } if config.HasOverridePath() { // Load overrides if a path was given. config.Overrides, err = conf.ReadConfigFile(config.OverridePath()) if err != nil { return } } for _, section := range config.Defaults.GetSections() { options, _ := config.Defaults.GetOptions(section) for _, option := range options { if !config.ConfigFile.HasOption(section, option) { value, _ := config.Defaults.GetRawString(section, option) config.ConfigFile.AddOption(section, option, value) } } } for _, section := range config.Overrides.GetSections() { options, _ := config.Overrides.GetOptions(section) for _, option := range options { value, _ := config.Overrides.GetRawString(section, option) config.ConfigFile.AddOption(section, option, value) } } return }