21 lines
349 B
Go
21 lines
349 B
Go
|
package duration
|
||
|
|
||
|
import "time"
|
||
|
|
||
|
// Duration just wraps time.Duration
|
||
|
type Duration struct {
|
||
|
time.Duration
|
||
|
}
|
||
|
|
||
|
// UnmarshalTOML parses the duration from the TOML config file
|
||
|
func (d *Duration) UnmarshalTOML(b []byte) error {
|
||
|
dur, err := time.ParseDuration(string(b[1 : len(b)-1]))
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
d.Duration = dur
|
||
|
|
||
|
return nil
|
||
|
}
|