From c7e6169f6f0747fbfff8914c3824a16de58ddf56 Mon Sep 17 00:00:00 2001 From: Carlo Alberto Ferraris Date: Mon, 22 Jan 2024 06:18:31 +0000 Subject: [PATCH] allow overriding the number of parallel builds --- main.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 87b3ac5..aa82b1a 100644 --- a/main.go +++ b/main.go @@ -14,6 +14,7 @@ import ( "path/filepath" "regexp" "runtime" + "strconv" "strings" "sync" "unicode" @@ -124,8 +125,13 @@ func main() { stdout := &lwriter{Writer: os.Stdout} stderr := &lwriter{Writer: os.Stderr} + np := runtime.NumCPU() + if pbi, _ := strconv.Atoi(os.Getenv("MGO_PARALLEL_BUILD")); pbi > 0 { + np = pbi + } + sema := make(chan struct{}, np) + eg, ctx := errgroup.WithContext(context.Background()) - sema := make(chan struct{}, runtime.NumCPU()) for _, v := range []string{"v1", "v2", "v3", "v4"} { v := v eg.Go(func() error {