mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-25 00:05:15 +00:00
bbgo: fix LooseFormatTime.UnmarshalYAML
This commit is contained in:
parent
8f0e80499b
commit
a29198f733
|
@ -184,7 +184,6 @@ func TestLoadConfig(t *testing.T) {
|
|||
assert.NotNil(t, config.Backtest.Account)
|
||||
assert.NotNil(t, config.Backtest.Account.Balances)
|
||||
assert.Len(t, config.Backtest.Account.Balances, 2)
|
||||
assert.NotEmpty(t, config.Backtest.StartTime)
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
@ -229,17 +229,17 @@ type LooseFormatTime time.Time
|
|||
|
||||
func (t *LooseFormatTime) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||
var str string
|
||||
if err := unmarshal(&str); err == nil {
|
||||
return t.UnmarshalJSON([]byte(str))
|
||||
if err := unmarshal(&str); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var bin []byte
|
||||
err := unmarshal(&bin)
|
||||
tv, err := util.ParseTimeWithFormats(str, looseTimeFormats)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return t.UnmarshalJSON(bin)
|
||||
*t = LooseFormatTime(tv)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t *LooseFormatTime) UnmarshalJSON(data []byte) error {
|
||||
|
|
Loading…
Reference in New Issue
Block a user