Code Room
Code reviewHard
Question
Review this Go code that removes expired sessions from a map while iterating.
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.
Learn the concepts
func reap(sessions map[string]Session, now time.Time) int { removed := 0 for id, s := range sessions { if s.expiresAt.Before(now) { delete(sessions, id) removed++ } if s.lastSeen.Add(idleTTL).Before(now) { sessions[id] = touch(s) // refresh non-expired idle ones } } return removed}Run or narrate your approach, then ask the coach.