mirror of
https://github.com/genuinetools/reg.git
synced 2024-09-28 11:46:20 -04:00
make ls faster (#48)
This commit is contained in:
parent
75dcff4501
commit
29f6d2fab9
1 changed files with 13 additions and 7 deletions
10
main.go
10
main.go
|
@ -7,6 +7,7 @@ import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync"
|
||||||
"text/tabwriter"
|
"text/tabwriter"
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
"github.com/Sirupsen/logrus"
|
||||||
|
@ -138,15 +139,20 @@ func main() {
|
||||||
// print header
|
// print header
|
||||||
fmt.Fprintln(w, "REPO\tTAGS")
|
fmt.Fprintln(w, "REPO\tTAGS")
|
||||||
|
|
||||||
|
var wg sync.WaitGroup
|
||||||
|
wg.Add(len(repos))
|
||||||
for _, repo := range repos {
|
for _, repo := range repos {
|
||||||
|
go func(repo string) {
|
||||||
// get the tags and print to stdout
|
// get the tags and print to stdout
|
||||||
tags, err := r.Tags(repo)
|
tags, err := r.Tags(repo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
fmt.Printf("Get tags of [%s] error: %s", repo, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Fprintf(w, "%s\t%s\n", repo, strings.Join(tags, ", "))
|
fmt.Fprintf(w, "%s\t%s\n", repo, strings.Join(tags, ", "))
|
||||||
|
wg.Done()
|
||||||
|
}(repo)
|
||||||
}
|
}
|
||||||
|
wg.Wait()
|
||||||
|
|
||||||
w.Flush()
|
w.Flush()
|
||||||
return nil
|
return nil
|
||||||
|
|
Loading…
Reference in a new issue