Code Room
Code reviewMedium
Question
Review this Go HTTP handler that returns a customer's audit-log entries. There is no `limit`, and customers with long histories time out.
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 auditHandler(w http.ResponseWriter, r *http.Request) { cust := r.URL.Query().Get("customer") rows, _ := db.Query("SELECT id, action, ts FROM audit WHERE customer=$1 ORDER BY ts DESC", cust) defer rows.Close() var out []Entry for rows.Next() { var e Entry rows.Scan(&e.ID, &e.Action, &e.Ts) out = append(out, e) } json.NewEncoder(w).Encode(out)}Run or narrate your approach, then ask the coach.