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