Code Room
Code reviewHardcr-g088
Subject Retry logicLevel Senior–Staff~30 minCommon in Code quality & review interviewsIndustries Software development

Question

Review this Go retry wrapper used across many concurrent goroutines.

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
func withRetry(ctx context.Context, fn func() error) error {	var err error	for attempt := 0; attempt < 5; attempt++ {		err = fn()		if err == nil {			return nil		}		delay := time.Duration(attempt*attempt) * time.Second		time.Sleep(delay)	}	return err}
Run or narrate your approach, then ask the coach.