Code Room
Code reviewHardcr-g085
Subject Blocking ioLevel Senior–Staff~30 minCommon in Code quality & review interviewsIndustries Software development

Question

Review this Go function that records each event.

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 recordEvent(dsn string, e Event) error {    db, err := sql.Open("postgres", dsn)   // called on every event    if err != nil {        return err    }    defer db.Close()    _, err = db.ExecContext(context.Background(),        "INSERT INTO events(name, ts) VALUES($1, $2)", e.Name, e.Ts)    return err}
Run or narrate your approach, then ask the coach.