Code Room
Code reviewMediumcr-g299
Subject N plus one queriesLevel Mid–Senior~18 minCommon in Code quality & review interviewsIndustries Software development, Technology

Question

Review this Go function that checks whether a feature flag is enabled for a tenant. The flags table is large and the function is called on nearly every request.

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 flagEnabled(db *sql.DB, tenant, flag string) bool {    rows, _ := db.Query("SELECT tenant, name, enabled FROM flags")    defer rows.Close()    for rows.Next() {        var t, n string        var en bool        rows.Scan(&t, &n, &en)        if t == tenant && n == flag {            return en        }    }    return false}
Run or narrate your approach, then ask the coach.