Make file parsing concurrent
This commit is contained in:
28
main.go
28
main.go
@@ -3,6 +3,7 @@ package main
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
lua "github.com/yuin/gopher-lua"
|
||||
"io"
|
||||
"log"
|
||||
"os"
|
||||
@@ -10,8 +11,7 @@ import (
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
lua "github.com/yuin/gopher-lua"
|
||||
"sync"
|
||||
)
|
||||
|
||||
var Error *log.Logger
|
||||
@@ -127,18 +127,24 @@ func main() {
|
||||
return
|
||||
}
|
||||
|
||||
var wg sync.WaitGroup
|
||||
// Process each file
|
||||
for _, file := range files {
|
||||
Info.Printf("🔄 Processing file: %s", file)
|
||||
err := processFile(file, pattern, luaExpr, originalLuaExpr)
|
||||
if err != nil {
|
||||
Error.Printf("❌ Failed to process file %s: %v", file, err)
|
||||
stats.FailedFiles++
|
||||
} else {
|
||||
Info.Printf("✅ Successfully processed file: %s", file)
|
||||
stats.ProcessedFiles++
|
||||
}
|
||||
wg.Add(1)
|
||||
go func(file string) {
|
||||
defer wg.Done()
|
||||
Info.Printf("🔄 Processing file: %s", file)
|
||||
err := processFile(file, pattern, luaExpr, originalLuaExpr)
|
||||
if err != nil {
|
||||
Error.Printf("❌ Failed to process file %s: %v", file, err)
|
||||
stats.FailedFiles++
|
||||
} else {
|
||||
Info.Printf("✅ Successfully processed file: %s", file)
|
||||
stats.ProcessedFiles++
|
||||
}
|
||||
}(file)
|
||||
}
|
||||
wg.Wait()
|
||||
|
||||
// Print summary of all modifications
|
||||
printSummary(originalLuaExpr)
|
||||
|
Reference in New Issue
Block a user