diff --git a/cmd/dep/root_analyzer.go b/cmd/dep/root_analyzer.go index b7d278fe25..9e775887f6 100644 --- a/cmd/dep/root_analyzer.go +++ b/cmd/dep/root_analyzer.go @@ -60,6 +60,8 @@ func (a *rootAnalyzer) cacheDeps(pr gps.ProjectRoot) { packages := make(map[string]bool) dependencies := make(map[gps.ProjectRoot][]string) logger := a.ctx.Err + concurrency := 4 + sem := make(chan bool, concurrency) syncDep := func(pr gps.ProjectRoot, sm gps.SourceManager) { if err := sm.SyncSourceFor(gps.ProjectIdentifier{ProjectRoot: pr}); err != nil { @@ -90,9 +92,16 @@ func (a *rootAnalyzer) cacheDeps(pr gps.ProjectRoot) { continue } - go syncDep(pr, a.sm) + sem <- true + go func() { + defer func() { <-sem }() + go syncDep(pr, a.sm) + }() dependencies[pr] = []string{ip} } + for i := 0; i < cap(sem); i++ { + sem <- true + } } func hasImportPathPrefix(s, prefix string) bool {