I have an Ember.js front end that is talking to a Go API server. I’m using Ember Data and things are working well except for dates.
In Go’s time.Time type, the zero value for dates is “0001-01-01 00:00:00 +0000 UTC”. Some of the dates in my app, such as the date on which a record is created, are generated by Go when it receives data from Ember. In this case Ember POSTs a new record to Go and then Go sends that date/time back to Ember in the JSON reponse. I wrote a custom transform that translates Go’s zero dates into a null value during deserialization for use within the Ember app. So when go sends “0001-01-01 00:00:00 +0000 UTC” to Ember, Ember replaces it with a null value. (We’re assuming throughout the app that the time zone is constant, so we’re hiding it from the users.) Then, when Ember serializes the dates, if an Ember date field is empty, it replaces the value with Go’s time.Time’s zero value which is “0001-01-01 00:00:00 +0000 UTC” and sends that to the server.
Does this generally seem like the right approach?