Code Room
Code reviewHardcr-g139
Subject Pagination bugsLevel Senior–Staff~25 minCommon in Networking & APIs interviewsIndustries Software development

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.

Talk through your review
Code to reviewgo
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.