Code Room
Code reviewHard
Question
Review this Go cursor-pagination endpoint.
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 ListEvents(w http.ResponseWriter, r *http.Request) { after := r.URL.Query().Get("after") // last seen id limit := 50 rows, _ := db.Query( "SELECT id, ts, body FROM events WHERE id > $1 ORDER BY ts ASC LIMIT $2", after, limit) var out []Event for rows.Next() { var e Event rows.Scan(&e.ID, &e.TS, &e.Body) out = append(out, e) } next := "" if len(out) == limit { next = out[len(out)-1].ID } json.Marshal(out) // returns []; cursor lost}Run or narrate your approach, then ask the coach.