Code Room
Code reviewHardcr-g071
Subject N plus one queriesLevel Senior–Staff~30 minCommon in Databases & SQL interviewsIndustries Software development, Technology

Question

Review this Go function.

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 enrichOrders(ctx context.Context, db *sql.DB, orders []Order) ([]OrderView, error) {    views := make([]OrderView, 0, len(orders))    for _, o := range orders {        var name string        err := db.QueryRowContext(ctx,            "SELECT name FROM users WHERE id = $1", o.UserID).Scan(&name)        if err != nil {            return nil, err        }        views = append(views, OrderView{Order: o, UserName: name})    }    return views, nil}
Run or narrate your approach, then ask the coach.