Code Room
Code reviewMediumcr-g648
Subject Query optimizationLevel Mid–Senior~22 minCommon in Databases & SQL interviewsIndustries Software development

Question

Review this Go code that enriches a list of comments with author names.

Comment lists routinely hold 200+ items.

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 enrich(db *sql.DB, comments []Comment) ([]EnrichedComment, error) {    out := make([]EnrichedComment, 0, len(comments))    for _, c := range comments {        var name string        err := db.QueryRow(            "SELECT name FROM users WHERE id = $1", c.AuthorID,        ).Scan(&name)        if err != nil {            return nil, err        }        out = append(out, EnrichedComment{Comment: c, Author: name})    }    return out, nil}
Run or narrate your approach, then ask the coach.