Code Room
Code reviewHard
Question
Review this Go circuit breaker wrapping a downstream call.
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
type Breaker struct { mu sync.Mutex failures int open bool} func (b *Breaker) Call(fn func() error) error { b.mu.Lock(); o := b.open; b.mu.Unlock() if o { return errors.New("circuit open") } err := fn() b.mu.Lock(); defer b.mu.Unlock() if err != nil { b.failures++ if b.failures >= 5 { b.open = true } } return err}Run or narrate your approach, then ask the coach.