Code Room
Code reviewHard
Question
Review this Go funds-transfer. It opens a transaction, debits, validates, then credits.
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 transfer(db *sql.DB, from, to string, amt int) error { tx, _ := db.Begin() tx.Exec("UPDATE acct SET bal = bal - $1 WHERE id = $2", amt, from) var bal int tx.QueryRow("SELECT bal FROM acct WHERE id = $1", from).Scan(&bal) if bal < 0 { return errors.New("insufficient funds") } tx.Exec("UPDATE acct SET bal = bal + $1 WHERE id = $2", amt, to) return tx.Commit()}Run or narrate your approach, then ask the coach.