Code Room
Code reviewMediumcr-g493
Subject Retry logicLevel Mid–Senior~16 minCommon in Code quality & review interviewsIndustries Software development, Technology

Question

Review this Go retry wrapper that retries a POST with a JSON body on transient failures.

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 postWithRetry(url string, body io.Reader) (*http.Response, error) {    var lastErr error    for attempt := 0; attempt < 3; attempt++ {        req, _ := http.NewRequest("POST", url, body)        resp, err := http.DefaultClient.Do(req)        if err == nil && resp.StatusCode < 500 {            return resp, nil        }        lastErr = err        time.Sleep(time.Duration(attempt) * 200 * time.Millisecond)    }    return nil, lastErr}
Run or narrate your approach, then ask the coach.