Code Room
Code reviewHardcr-g002
Subject DeadlocksLevel Senior–Staff~30 minCommon in Concurrency interviewsIndustries Software development

Question

Review this Go account-transfer function.

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
type Account struct {	mu      sync.Mutex	balance int64} func Transfer(from, to *Account, amt int64) {	from.mu.Lock()	defer from.mu.Unlock()	to.mu.Lock()	defer to.mu.Unlock()	from.balance -= amt	to.balance += amt}
Run or narrate your approach, then ask the coach.