Code Room
Code reviewHardcr-g219
Subject Channel misuseLevel Mid–Senior~35 minCommon in Code quality & review interviewsIndustries Software development

Question

Review this Go fan-out helper that returns the first successful result.

What goes wrong here?

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 fastest(ctx context.Context, urls []string) (string, error) {    results := make(chan string)            // unbuffered    for _, u := range urls {        go func(u string) {            body, err := fetch(ctx, u)            if err == nil {                results <- body            // (1)            }        }(u)    }    select {    case r := <-results:        return r, nil    case <-ctx.Done():        return "", ctx.Err()    }}
Run or narrate your approach, then ask the coach.