File tree Expand file tree Collapse file tree 3 files changed +9
-16
lines changed
Expand file tree Collapse file tree 3 files changed +9
-16
lines changed Original file line number Diff line number Diff line change @@ -22,11 +22,10 @@ import (
2222 "sort"
2323 "strconv"
2424 "strings"
25- "sync"
2625 "time"
2726
2827 kingpin "github.com/alecthomas/kingpin/v2"
29- "go.uber. org/atomic "
28+ "golang. org/x/sync/errgroup "
3029
3130 "github.com/prometheus/promu/util/sh"
3231)
@@ -190,19 +189,13 @@ func (pg platformGroup) Build(repoPath string) error {
190189 if err != nil {
191190 return err
192191 }
193- var wg sync.WaitGroup
194- wg .Add (* parallelFlag )
195- atomicErr := atomic .NewError (nil )
192+ var g errgroup.Group
196193 for p := 0 ; p < * parallelFlag ; p ++ {
197- go func (p int ) {
198- defer wg .Done ()
199- if err := pg .buildThread (repoPath , p ); err != nil {
200- atomicErr .Store (err )
201- }
202- }(p )
194+ g .Go (func () error {
195+ return pg .buildThread (repoPath , p )
196+ })
203197 }
204- wg .Wait ()
205- return atomicErr .Load ()
198+ return g .Wait ()
206199}
207200
208201func (pg platformGroup ) buildThread (repoPath string , p int ) error {
Original file line number Diff line number Diff line change @@ -7,9 +7,9 @@ require (
77 github.com/alecthomas/kingpin/v2 v2.4.0
88 github.com/google/go-github/v25 v25.1.3
99 github.com/prometheus/common v0.67.5
10- go.uber.org/atomic v1.11.0
1110 go.yaml.in/yaml/v2 v2.4.4
1211 golang.org/x/oauth2 v0.36.0
12+ golang.org/x/sync v0.20.0
1313)
1414
1515require (
Original file line number Diff line number Diff line change @@ -28,8 +28,6 @@ github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu
2828github.1485827954.workers.dev/stretchr/testify v1.11.1 /go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U =
2929github.1485827954.workers.dev/xhit/go-str2duration/v2 v2.1.0 h1:lxklc02Drh6ynqX+DdPyp5pCKLUQpRT8bp8Ydu2Bstc =
3030github.1485827954.workers.dev/xhit/go-str2duration/v2 v2.1.0 /go.mod h1:ohY8p+0f07DiV6Em5LKB0s2YpLtXVyJfNt1+BlmyAsU =
31- go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE =
32- go.uber.org/atomic v1.11.0 /go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0 =
3331go.yaml.in/yaml/v2 v2.4.4 h1:tuyd0P+2Ont/d6e2rl3be67goVK4R6deVxCUX5vyPaQ =
3432go.yaml.in/yaml/v2 v2.4.4 /go.mod h1:gMZqIpDtDqOfM0uNfy0SkpRhvUryYH0Z6wdMYcacYXQ =
3533golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 /go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w =
@@ -38,6 +36,8 @@ golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAG
3836golang.org/x/oauth2 v0.36.0 h1:peZ/1z27fi9hUOFCAZaHyrpWG5lwe0RJEEEeH0ThlIs =
3937golang.org/x/oauth2 v0.36.0 /go.mod h1:YDBUJMTkDnJS+A4BP4eZBjCqtokkg1hODuPjwiGPO7Q =
4038golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6 /go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM =
39+ golang.org/x/sync v0.20.0 h1:e0PTpb7pjO8GAtTs2dQ6jYa5BWYlMuX047Dco/pItO4 =
40+ golang.org/x/sync v0.20.0 /go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0 =
4141golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a /go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY =
4242golang.org/x/text v0.3.0 /go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ =
4343google.golang.org/appengine v1.1.0 /go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM =
You can’t perform that action at this time.
0 commit comments