type Duration … func (d Duration) String() string { … } // MarshalJSON converts from d to a JSON string output. func (d Duration) MarshalJSON() ([]byte, error) { … } // UnmarshalJSON unmarshals b as a duration JSON string into d. func (d *Duration) UnmarshalJSON(b []byte) error { … }