Code RoomTimestamp unit mismatch
MediumPrep Room Coding #1962

Timestamp unit mismatch

Code reviewCode quality & reviewMid–Senior~16 min

Review this Go code that decodes a timestamp field from an incoming event and stores it.

What a strong answer looks like

Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix, specific and kind.

0:00 of about 16 min
Mark a line and say what kind of problem it is.0 findings
1type Event struct {
2 TS int64 `json:"ts"` // producer A sends seconds; producer B sends milliseconds
3}
4 
5func decode(b []byte) (time.Time, error) {
6 var e Event
7 if err := json.Unmarshal(b, &e); err != nil {
8 return time.Time{}, err
9 }
10 return time.Unix(e.TS, 0), nil // store as time
11}
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.