Code Room
Code reviewHardcr-g356
Subject Leaky abstractionsLevel Senior–Staff~25 minCommon in Networking & APIs interviewsIndustries Software development, Technology

Question

Review this Go API that returns a pagination cursor to clients.

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
type Page struct {    Items      []Doc  `json:"items"`    NextCursor string `json:"next_cursor"`} func listDocs(w http.ResponseWriter, r *http.Request) {    cur := r.URL.Query().Get("cursor") // raw DB offset, e.g. "40"    offset, _ := strconv.Atoi(cur)    docs := repo.Find(offset, 20)      // SELECT ... OFFSET ?    next := strconv.Itoa(offset + 20)    json.NewEncoder(w).Encode(Page{Items: docs, NextCursor: next})}
Run or narrate your approach, then ask the coach.