sdk-go
sdk-go copied to clipboard
Properly marshal event time to RFC-3339 format
In event_marshal.go, time.String()
is currently used to marshal the time to a string: https://github.com/cloudevents/sdk-go/blob/ba92a5c9a1e2508d855930049999ccd75636f0cb/v2/event/event_marshal.go#L76-L79
However, in the go time.Time
documentation, it says about the method time.Time.String()
:
The returned string is meant for debugging; for a stable serialized representation, use t.MarshalText, t.MarshalBinary, or t.Format with an explicit format string.
In the Spec, it is required that the time is serialized to RFC-3339, so we should be using time.Time.MarshalText
instead
Or time.Format() with RFC3339 - wanna submit a PR?
Happy to open a PR, but I know @MaryamTaj has been wanting to make some contributions so I'll see if she is interested in this one first :)
@duglin I would love to work on this!
Commented in the PR to discuss whether this must be considered a breaking change.