Code Room
Code reviewHardcr-g304
Subject Retry logicLevel Senior–Staff~22 minCommon in Code quality & review interviewsIndustries Software development, Technology

Question

Review this Go retry helper used by every instance of a fleet to call a shared downstream. It already retries on error.

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 fetch(ctx context.Context, url string) (*http.Response, error) {    var lastErr error    for i := 0; i < 5; i++ {        resp, err := http.Get(url)        if err == nil && resp.StatusCode < 500 {            return resp, nil        }        lastErr = err        time.Sleep(50 * time.Millisecond)    }    return nil, lastErr}
Run or narrate your approach, then ask the coach.