Make async
This commit is contained in:
31
main.go
31
main.go
@@ -7,6 +7,7 @@ import (
|
||||
"log"
|
||||
"os"
|
||||
"strings"
|
||||
"sync"
|
||||
"text/template"
|
||||
|
||||
"github.com/PuerkitoBio/goquery"
|
||||
@@ -58,20 +59,26 @@ func main() {
|
||||
return
|
||||
}
|
||||
|
||||
wg := sync.WaitGroup{}
|
||||
for _, file := range files {
|
||||
class, err := ParseFile(file)
|
||||
if err != nil {
|
||||
Error.Printf("Error parsing file: %v", err)
|
||||
continue
|
||||
}
|
||||
wg.Add(1)
|
||||
go func(file string) {
|
||||
defer wg.Done()
|
||||
class, err := ParseFile(file)
|
||||
if err != nil {
|
||||
Error.Printf("Error parsing file: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
outfile, err := class.GetOutFile()
|
||||
if err != nil {
|
||||
Error.Printf("Error creating output file: %v", err)
|
||||
return
|
||||
}
|
||||
ltemplate.Execute(outfile, class)
|
||||
outfile, err := class.GetOutFile()
|
||||
if err != nil {
|
||||
Error.Printf("Error creating output file: %v", err)
|
||||
return
|
||||
}
|
||||
ltemplate.Execute(outfile, class)
|
||||
}(file)
|
||||
}
|
||||
wg.Wait()
|
||||
}
|
||||
|
||||
func ParseFile(filename string) (*Class, error) {
|
||||
@@ -156,7 +163,7 @@ func ParseFile(filename string) (*Class, error) {
|
||||
res.Methods = append(res.Methods, method)
|
||||
})
|
||||
|
||||
// spew.Dump(res)
|
||||
spew.Dump(res)
|
||||
|
||||
return &res, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user