Code Room
Code reviewHard
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.
Learn the concepts
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.