forked from External/ergo
use custime.Duration for more config fields
This commit is contained in:
parent
7b3caed20f
commit
ef161c47ed
6 changed files with 38 additions and 27 deletions
|
|
@ -182,3 +182,18 @@ func ParseDuration(s string) (time.Duration, error) {
|
|||
}
|
||||
return time.Duration(d), nil
|
||||
}
|
||||
|
||||
type Duration time.Duration
|
||||
|
||||
func (d *Duration) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||
var orig string
|
||||
var err error
|
||||
if err = unmarshal(&orig); err != nil {
|
||||
return err
|
||||
}
|
||||
result, err := ParseDuration(orig)
|
||||
if err == nil {
|
||||
*d = Duration(result)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue