Skip to content
This repository was archived by the owner on Mar 27, 2024. It is now read-only.

Commit ee51ff8

Browse files
committed
fix channel read
1 parent 8621bc5 commit ee51ff8

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

cmd/diff.go

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package cmd
1919
import (
2020
"fmt"
2121
"os"
22+
"strings"
2223
"sync"
2324

2425
"github.com/GoogleContainerTools/container-diff/cmd/util/output"
@@ -100,17 +101,19 @@ func diffImages(image1Arg, image2Arg string, diffArgs []string) error {
100101
go processImage(image2Arg, imageMap, &wg, errChan)
101102

102103
wg.Wait()
103-
err, ok := <-errChan
104-
errs := []error{}
105-
if ok {
106-
errs = append(errs, err)
104+
close(errChan)
105+
106+
errs := []string{}
107+
for {
108+
err, ok := <-errChan
109+
if !ok {
110+
break
111+
}
112+
errs = append(errs, err.Error())
107113
}
114+
108115
if len(errs) > 0 {
109-
errStr := ""
110-
for _, err := range errs {
111-
errStr = errStr + err.Error()
112-
}
113-
return errors.New(errStr)
116+
return errors.New(strings.Join(errs, "\n"))
114117
}
115118

116119
img1, ok := imageMap[image1Arg]

0 commit comments

Comments
 (0)