From f5ac829804b3444786677b8ac96c56e6bb50d753 Mon Sep 17 00:00:00 2001 From: Alan Donovan Date: Wed, 4 Sep 2013 14:32:36 -0400 Subject: [PATCH] go.tools/importer: fix classic closing-over-induction-variable gotcha. Now we actually prefetch all n packages, instead of prefetching the last one n times. This yields a further 22% improvement, which is more like what I was hoping for. It makes me so sad that Go reproduced one of the best-known mistakes of JavaScript. D'oh! R=crawshaw CC=golang-dev https://golang.org/cl/13379046 --- importer/importer.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/importer/importer.go b/importer/importer.go index 6c7a1610eb8..cd004987b9b 100644 --- a/importer/importer.go +++ b/importer/importer.go @@ -177,7 +177,7 @@ func (imp *Importer) LoadPackage(importPath string) (*PackageInfo, error) { if files, err := loadPackage(imp.config.Build, imp.Fset, importPath); err == nil { // Kick off asynchronous I/O and parsing for the imports. for path := range imports(importPath, files) { - go func() { imp.LoadPackage(path) }() + go func(path string) { imp.LoadPackage(path) }(path) } // Type-check the package.