with capture

This commit is contained in:
Kasper Juul Hermansen 2022-10-30 15:46:52 +01:00
parent 81bf4841b8
commit 6403f26cd7
Signed by: kjuulh
GPG Key ID: 0F95C140730F2F23

4
byg.go
View File

@ -2,6 +2,7 @@ package byg
import (
"context"
"log"
"sync"
"golang.org/x/sync/errgroup"
@ -52,12 +53,15 @@ func (bb *Builder) Execute(ctx context.Context) error {
defer bb.addmu.Unlock()
for _, step := range bb.steps {
log.Printf("executing step: %s", step.name)
errgroup, _ := errgroup.WithContext(ctx)
for _, task := range step.tasks {
func(task StepExecuteFunc) {
errgroup.Go(func() error {
return task(Context{})
})
}(task)
}
if err := errgroup.Wait(); err != nil {