Use empty config if config file doesn't exist

This commit is contained in:
Larry850806 2021-03-17 20:03:27 +08:00
parent 4dc478590f
commit 28f4584191

View File

@ -33,12 +33,20 @@ var balancesCmd = &cobra.Command{
return errors.New("--config option is required")
}
if _, err := os.Stat(configFile); os.IsNotExist(err) {
// if config file exists, use the config loaded from the config file.
// otherwise, use a empty config object
var userConfig *bbgo.Config
if _, err := os.Stat(configFile); err == nil {
// load successfully
userConfig, err = bbgo.Load(configFile, false)
if err != nil {
return err
}
userConfig, err := bbgo.Load(configFile, false)
if err != nil {
} else if os.IsNotExist(err) {
// config file doesn't exist
userConfig = &bbgo.Config{}
} else {
// other error
return err
}