Moving the Duration wrapper to it's own package to break import loops.

This commit is contained in:
gotyaoi
2015-10-16 23:10:14 -07:00
committed by Ellison Marks
parent d77cfd6ecc
commit 0299a17da1
6 changed files with 31 additions and 27 deletions

20
duration/duration.go Normal file
View File

@@ -0,0 +1,20 @@
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
}