Open Semior001 opened 1 year ago
do you want just to change types like below
type Range struct {
St time.Time `json:"st"`
Dur time.Duration `json:"dur"`
}
or do you want to also add methods to marshall/unmarshall them ?
I think it would be nice if we marshal it as {"start": "2006-01-02T15:04:05Z07:00", "end": "2006-01-02T15:04:05Z07:00"}
. At least among my cases it is rarely needed to get the duration in json, but it is often needed to use the end time.
This would involve implementing marshal/unmarshal methods for the type.
The type doesnt have end as attribute right ? are we going to add another struct using the range struct just for this usage ?
The type doesnt have end as attribute right ?
Yes, type doesn't have the end time among its fields. That was done purposefully, so we won't have to keep an eye on the consistency between the start and end time, so we don't want the end field to be added to the type.
are we going to add another struct using the range struct just for this usage ?
That would be the option. Another struct that would be used just to marshal/unmarshal the period itself.
Right now these types don't support marshal/unmarshal from/to json, but implementing this might be pretty handy in the future.