Code Room
Code reviewHard
Question
Review this Go circuit breaker.
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 { failures int open bool openedAt time.Time} func (b *Breaker) Call(fn func() error) error { if b.open && time.Since(b.openedAt) < 30*time.Second { return ErrOpen } err := fn() if err != nil { b.failures++ if b.failures >= 5 { b.open = true b.openedAt = time.Now() } return err } b.failures = 0 return nil}Run or narrate your approach, then ask the coach.