From 81595258be6d2b4237bd08b527385335609edb69 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 5 Jun 2013 17:46:23 -0700 Subject: [PATCH] command/build: Lexical scoping bug to get the right build --- command/build/command.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/command/build/command.go b/command/build/command.go index 42188e009..9560b1cd4 100644 --- a/command/build/command.go +++ b/command/build/command.go @@ -128,16 +128,16 @@ func (c Command) Run(env packer.Environment, args []string) int { var wg sync.WaitGroup artifacts := make(map[string]packer.Artifact) for _, b := range builds { - log.Printf("Starting build run: %s", b.Name()) - // Increment the waitgroup so we wait for this item to finish properly wg.Add(1) // Run the build in a goroutine - go func() { + go func(b packer.Build) { defer wg.Done() + + log.Printf("Starting build run: %s", b.Name()) artifacts[b.Name()] = b.Run(buildUis[b.Name()]) - }() + }(b) } // Handle signals