mirror of
https://github.com/genuinetools/reg.git
synced 2024-06-30 11:04:16 -04:00
Locking around ls writes to tabwriter (#55)
Fixes #54 Signed-off-by: Matt Vinall <boyvinall@gmail.com>
This commit is contained in:
parent
cde5e3cc1f
commit
22cbb0f2a0
3
main.go
3
main.go
|
@ -140,6 +140,7 @@ func main() {
|
||||||
// print header
|
// print header
|
||||||
fmt.Fprintln(w, "REPO\tTAGS")
|
fmt.Fprintln(w, "REPO\tTAGS")
|
||||||
|
|
||||||
|
var l sync.Mutex
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
wg.Add(len(repos))
|
wg.Add(len(repos))
|
||||||
for _, repo := range repos {
|
for _, repo := range repos {
|
||||||
|
@ -150,7 +151,9 @@ func main() {
|
||||||
fmt.Printf("Get tags of [%s] error: %s", repo, err)
|
fmt.Printf("Get tags of [%s] error: %s", repo, err)
|
||||||
}
|
}
|
||||||
out := fmt.Sprintf("%s\t%s\n", repo, strings.Join(tags, ", "))
|
out := fmt.Sprintf("%s\t%s\n", repo, strings.Join(tags, ", "))
|
||||||
|
l.Lock()
|
||||||
w.Write([]byte(out))
|
w.Write([]byte(out))
|
||||||
|
l.Unlock()
|
||||||
wg.Done()
|
wg.Done()
|
||||||
}(repo)
|
}(repo)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue