Config: Interpret empty duration strings as duration = 0.
In practice, we allowed this already, because parsing failed but Validate() succeeded. License: MIT Signed-off-by: Hector Sanjuan <code@hector.link>
This commit is contained in:
parent
5075504926
commit
e891c33e40
|
@ -96,6 +96,10 @@ type DurationOpt struct {
|
|||
// ParseDurations takes a time.Duration src and saves it to the given dst.
|
||||
func ParseDurations(component string, args ...*DurationOpt) error {
|
||||
for _, arg := range args {
|
||||
if arg.Duration == "" {
|
||||
*arg.Dst = 0
|
||||
continue
|
||||
}
|
||||
t, err := time.ParseDuration(arg.Duration)
|
||||
if err != nil {
|
||||
return fmt.Errorf(
|
||||
|
|
Loading…
Reference in New Issue
Block a user