Skip to content

Commit f2a6fa3

Browse files
committed
close the channel properly
1 parent 600661a commit f2a6fa3

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

tools/amplify-preview/amplify.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"errors"
66
"fmt"
77
"strings"
8+
"sync"
89
"time"
910

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

4851
for _, appID := range amp.appIDs {
4952
go func() {
53+
defer wg.Done()
5054
branch, err := amp.client.GetBranch(ctx, &amplify.GetBranchInput{
5155
AppId: aws.String(appID),
5256
BranchName: aws.String(branchName),
@@ -56,10 +60,12 @@ func (amp *AmplifyPreview) FindExistingBranch(ctx context.Context, branchName st
5660
data: branch,
5761
err: err,
5862
}
59-
6063
}()
6164
}
6265

66+
wg.Wait()
67+
close(resultCh)
68+
6369
failedResp := aggregatedError{
6470
perAppErr: map[string]error{},
6571
message: "failed to fetch branch",

0 commit comments

Comments
 (0)