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

Commit a98a37b

Browse files
tommyknowsnritholtz
authored andcommitted
Implement parallel cloning (#6)
1 parent b716b8c commit a98a37b

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

main.go

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"os"
77
"os/exec"
88
"path/filepath"
9+
"sync"
910

1011
"github.com/jessevdk/go-flags"
1112
"github.com/nritholtz/stdemuxerhook"
@@ -68,10 +69,17 @@ func main() {
6869
}
6970

7071
// Clone modules
71-
os.RemoveAll(opts.ModulePath)
72-
os.MkdirAll(opts.ModulePath, os.ModePerm)
73-
for key, module := range config {
74-
gitClone(module.Source, module.Version, key)
75-
os.RemoveAll(filepath.Join(opts.ModulePath, key, ".git"))
72+
var wg sync.WaitGroup
73+
_ = os.RemoveAll(opts.ModulePath)
74+
_ = os.MkdirAll(opts.ModulePath, os.ModePerm)
75+
for key, mod := range config {
76+
wg.Add(1)
77+
go func(m module, key string) {
78+
defer wg.Done()
79+
gitClone(m.Source, m.Version, key)
80+
_ = os.RemoveAll(filepath.Join(opts.ModulePath, key, ".git"))
81+
}(mod, key)
7682
}
83+
84+
wg.Wait()
7785
}

0 commit comments

Comments
 (0)