Code Room
Code reviewHardcr-g294
Subject Unnecessary allocationLevel Senior–Staff~20 minCommon in Code quality & review interviewsIndustries Software development

Question

Review this Go function that builds a slice of ids from a large result set. It shows up high in allocation profiles.

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 collectIDs(rows []Row) []int64 {    var ids []int64    for _, r := range rows {        ids = append(ids, r.ID)    }    return ids}
Run or narrate your approach, then ask the coach.