From 2e44075f88cd21a630b2af0ed9923276297f3be0 Mon Sep 17 00:00:00 2001 From: Sunny Date: Thu, 7 Sep 2017 17:03:22 +0530 Subject: [PATCH] add a BasicStatus channel --- cmd/dep/status.go | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/cmd/dep/status.go b/cmd/dep/status.go index a805ee8ff3..22e7db8097 100644 --- a/cmd/dep/status.go +++ b/cmd/dep/status.go @@ -363,10 +363,8 @@ func runStatusAll(ctx *dep.Ctx, out outputter, p *dep.Project, sm gps.SourceMana logger.Println("Checking upstream projects:") - // A map of ProjectRoot and *BasicStatus. This is used in maintain the - // order of BasicStatus in output by collecting all the BasicStatus and - // then using them in order. - bsMap := make(map[string]*BasicStatus) + // BasicStatus channel + bsCh := make(chan *BasicStatus, len(slp)) var wg sync.WaitGroup @@ -447,14 +445,23 @@ func runStatusAll(ctx *dep.Ctx, out outputter, p *dep.Project, sm gps.SourceMana } } - bsMap[bs.ProjectRoot] = &bs + bsCh <- &bs }(proj) } wg.Wait() + close(bsCh) logger.Println() + // A map of ProjectRoot and *BasicStatus. This is used in maintain the + // order of BasicStatus in output by collecting all the BasicStatus and + // then using them in order. + bsMap := make(map[string]*BasicStatus) + for bs := range bsCh { + bsMap[bs.ProjectRoot] = bs + } + // Use the collected BasicStatus in outputter for _, proj := range slp { out.BasicLine(bsMap[string(proj.Ident().ProjectRoot)])