var wg sync.WaitGroup wg.Add(len(work)) sem := make(chan struct{}, 10) wgDone := make(chan bool) for i < len(work)-1 { go func() { defer wg.Done()