Code Room
Code reviewMediumcr-g424
Subject Channel misuseLevel Mid–Senior~26 minCommon in Code quality & review interviewsIndustries Software development

Question

Review this Go streaming aggregator. Producers send partial results; a coordinator closes the channel on the first 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 run(items []Item) error {	results := make(chan int)	var wg sync.WaitGroup	for _, it := range items {		wg.Add(1)		go func(it Item) {			defer wg.Done()			v, err := process(it)			if err != nil {				close(results)   // signal failure				return			}			results <- v		}(it)	}	go func() { wg.Wait(); close(results) }()	total := 0	for v := range results {		total += v	}	return nil}
Run or narrate your approach, then ask the coach.