From adff5c79871ee8f7edac3b61febb4b903aaba0e8 Mon Sep 17 00:00:00 2001 From: Pavol Noha Date: Wed, 6 Jun 2018 13:59:55 +0200 Subject: [PATCH] fix go routine scope --- swarmpit/task/stats.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/swarmpit/task/stats.go b/swarmpit/task/stats.go index 1b4d155..f9ef398 100644 --- a/swarmpit/task/stats.go +++ b/swarmpit/task/stats.go @@ -121,14 +121,15 @@ func ContainersUsage(cli *client.Client) (stats []ContainerStatus) { mux := &sync.Mutex{} for _, v := range resp { - go func() { + go func(v types.Container) { defer wg.Done() var stat = ContainerUsage(cli, v.ID); mux.Lock() stats = append(stats, stat) mux.Unlock() - }() + }(v) } + wg.Wait() return }