Fix NewConfig function
Move the default setting before validating the config, otherwise the code will never run. This happens because the `Validate()` function will always fail when `config.Default.ConfigDir` is empty.
This commit is contained in:
parent
067197c1b5
commit
c523032c86
1 changed files with 3 additions and 3 deletions
|
|
@ -100,12 +100,12 @@ func NewConfig(cfgFile string) (*Config, error) {
|
|||
if _, err := toml.DecodeFile(cfgFile, &config); err != nil {
|
||||
return nil, errors.Wrap(err, "decoding toml")
|
||||
}
|
||||
if err := config.Validate(); err != nil {
|
||||
return nil, errors.Wrap(err, "validating config")
|
||||
}
|
||||
if config.Default.ConfigDir == "" {
|
||||
config.Default.ConfigDir = DefaultConfigDir
|
||||
}
|
||||
if err := config.Validate(); err != nil {
|
||||
return nil, errors.Wrap(err, "validating config")
|
||||
}
|
||||
return &config, nil
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue