Locking around ls writes to tabwriter (#55)

Fixes #54

Signed-off-by: Matt Vinall <boyvinall@gmail.com>
This commit is contained in:
Matt Vinall 2018-01-09 01:17:21 +00:00 committed by Jess Frazelle
parent cde5e3cc1f
commit 22cbb0f2a0

View file

@ -140,6 +140,7 @@ func main() {
// print header
fmt.Fprintln(w, "REPO\tTAGS")
var l sync.Mutex
var wg sync.WaitGroup
wg.Add(len(repos))
for _, repo := range repos {
@ -150,7 +151,9 @@ func main() {
fmt.Printf("Get tags of [%s] error: %s", repo, err)
}
out := fmt.Sprintf("%s\t%s\n", repo, strings.Join(tags, ", "))
l.Lock()
w.Write([]byte(out))
l.Unlock()
wg.Done()
}(repo)
}