From a99fc848a49f0f40e745e2c2fd2e22a9c580acc8 Mon Sep 17 00:00:00 2001 From: Yu Liu Date: Fri, 24 May 2024 16:45:50 +0000 Subject: [PATCH] Pass the parameters to goroutine to avoid relying on a go 1.22 fix. Bug: 335718784 Test: CI Change-Id: Iae55e59a58101bc373666455ae4f2b6146c1abca --- context.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/context.go b/context.go index 16841ae..e3395bf 100644 --- a/context.go +++ b/context.go @@ -4514,7 +4514,7 @@ func (c *Context) writeAllModuleActions(nw *ninjaWriter, shardNinja bool, ninjaF shardedModules := proptools.ShardByCount(modules, len(fileNames)) ninjaShardCnt := len(shardedModules) for i, batchModules := range shardedModules { - go func() { + go func(i int, batchModules []*moduleInfo) { f, err := os.OpenFile(filepath.Join(c.SrcDir(), fileNames[i]), os.O_WRONLY|os.O_CREATE|os.O_TRUNC, OutFilePermissions) if err != nil { errorCh <- fmt.Errorf("error opening Ninja file: %s", err) @@ -4525,7 +4525,7 @@ func (c *Context) writeAllModuleActions(nw *ninjaWriter, shardNinja bool, ninjaF defer buf.Flush() writer := newNinjaWriter(buf) errorCh <- c.writeModuleAction(batchModules, writer, headerTemplate) - }() + }(i, batchModules) nw.Subninja(fileNames[i]) }