Skip to content

Commit

Permalink
close the channel properly
Browse files Browse the repository at this point in the history
  • Loading branch information
taraspos committed Dec 11, 2024
1 parent 600661a commit f2a6fa3
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion tools/amplify-preview/amplify.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"errors"
"fmt"
"strings"
"sync"
"time"

"github.com/aws/aws-sdk-go-v2/service/amplify"
Expand Down Expand Up @@ -43,10 +44,13 @@ func (amp *AmplifyPreview) FindExistingBranch(ctx context.Context, branchName st
data *amplify.GetBranchOutput
err error
}
var wg sync.WaitGroup
wg.Add(len(amp.appIDs))
resultCh := make(chan resp, len(amp.appIDs))

for _, appID := range amp.appIDs {
go func() {
defer wg.Done()
branch, err := amp.client.GetBranch(ctx, &amplify.GetBranchInput{
AppId: aws.String(appID),
BranchName: aws.String(branchName),
Expand All @@ -56,10 +60,12 @@ func (amp *AmplifyPreview) FindExistingBranch(ctx context.Context, branchName st
data: branch,
err: err,
}

}()
}

wg.Wait()
close(resultCh)

failedResp := aggregatedError{
perAppErr: map[string]error{},
message: "failed to fetch branch",
Expand Down

0 comments on commit f2a6fa3

Please sign in to comment.