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