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