It seems obvious (to me) that the encoding.TextUnmarshaler interface could 
be implemented for time.Duration (it is implemented for time.Time, 
afterall).

The fact that it is not gives me pause... is there a good reason that the 
stdlib has not done this?  What issues am I facing if I do this: 
https://go.dev/play/p/nHBfS7TJQtJ

```
// UnmarshalText implements the encoding.TextUnmarshaler interface.
func (d *Duration) UnmarshalText(data []byte) error {
        val, err := time.ParseDuration(string(data))
        *d = Duration(val)
        return err
}
```

Cheers,
Corin.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/4f4029b8-cf01-4a71-837f-2002b398158en%40googlegroups.com.

Reply via email to