Code Room
Code reviewHard
Question
Review this Go list endpoint with client-controlled sorting.
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 ListUsers(w http.ResponseWriter, r *http.Request) { sortBy := r.URL.Query().Get("sort") // e.g. "name", "created_at" order := r.URL.Query().Get("order") // "asc" / "desc" query := fmt.Sprintf( "SELECT id, name FROM users ORDER BY %s %s", sortBy, order) rows, err := db.Query(query) if err != nil { http.Error(w, "error", 500); return } // ... scan and return}Run or narrate your approach, then ask the coach.