Fix panic in internal.Duration UnmarshalTOML
This commit is contained in:
parent
c849b58de9
commit
662db7a944
|
@ -35,10 +35,13 @@ type Duration struct {
|
||||||
// UnmarshalTOML parses the duration from the TOML config file
|
// UnmarshalTOML parses the duration from the TOML config file
|
||||||
func (d *Duration) UnmarshalTOML(b []byte) error {
|
func (d *Duration) UnmarshalTOML(b []byte) error {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
// Parse string duration, ie, "1s"
|
// Parse string duration, ie, "1s"
|
||||||
d.Duration, err = time.ParseDuration(string(b[1 : len(b)-1]))
|
if uq, err := strconv.Unquote(string(b)); err == nil && len(uq) > 0 {
|
||||||
if err == nil {
|
d.Duration, err = time.ParseDuration(uq)
|
||||||
return nil
|
if err == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// First try parsing as integer seconds
|
// First try parsing as integer seconds
|
||||||
|
|
Loading…
Reference in New Issue