Skip to content

Commit f6b214e

Browse files
authored
feat: make util.Duration implement the TextUnmarshaler interface (#220)
1 parent 3e3e6d8 commit f6b214e

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

util/duration.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ func (d *Duration) UnmarshalJSON(b []byte) error {
4040
return d.setValue(v)
4141
}
4242

43+
func (d *Duration) UnmarshalText(text []byte) error {
44+
return d.setValue(string(text))
45+
}
46+
4347
func (d *Duration) setValue(v interface{}) error {
4448
switch value := v.(type) {
4549
case float64:

0 commit comments

Comments
 (0)