mirror of
https://github.com/onyx-and-iris/gignore.git
synced 2025-03-31 10:51:19 +01:00
create templates concurrently
This commit is contained in:
parent
c2b7dfcb18
commit
fcb23a3c01
@ -44,7 +44,7 @@ tasks:
|
||||
generate:
|
||||
desc: Generate the gitignore.io templates
|
||||
cmds:
|
||||
- go generate .
|
||||
- go generate ./...
|
||||
|
||||
build-windows:
|
||||
desc: Build the gignore project for Windows
|
||||
|
@ -20,10 +20,25 @@ func main() {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
errChan := make(chan error)
|
||||
doneChan := make(chan struct{})
|
||||
|
||||
for _, template := range templates {
|
||||
err := createTemplate(template)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Failed to create template %s: %v\n", template.Name, err)
|
||||
go func() {
|
||||
err := createTemplate(template)
|
||||
if err != nil {
|
||||
errChan <- fmt.Errorf("Failed to create template %s: %v", template.Name, err)
|
||||
return
|
||||
}
|
||||
doneChan <- struct{}{}
|
||||
}()
|
||||
}
|
||||
|
||||
for range templates {
|
||||
select {
|
||||
case err := <-errChan:
|
||||
log.Error(err)
|
||||
case <-doneChan:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user