|
|
@@ -77,31 +77,31 @@ func GetGOBIN() string {
|
|
|
return GOBIN
|
|
|
}
|
|
|
|
|
|
-func Run(binary string, args []string) (string, error) {
|
|
|
+func Run(binary string, args []string) ([]byte, error) {
|
|
|
cmd := exec.Command(binary, args...)
|
|
|
cmd.Env = append(cmd.Env, os.Environ()...)
|
|
|
output, cmdErr := cmd.CombinedOutput()
|
|
|
if cmdErr != nil {
|
|
|
- return "", cmdErr
|
|
|
+ return nil, cmdErr
|
|
|
}
|
|
|
- if len(output) > 0 {
|
|
|
- return string(output), nil
|
|
|
- }
|
|
|
- return "", nil
|
|
|
+ return output, nil
|
|
|
}
|
|
|
|
|
|
func RunMany(binary string, args, files []string) {
|
|
|
fmt.Println("Processing...")
|
|
|
+
|
|
|
+ maxTasks := make(chan struct{}, runtime.NumCPU())
|
|
|
for _, file := range files {
|
|
|
- args := append(args, file)
|
|
|
- output, err := Run(binary, args)
|
|
|
- if err != nil {
|
|
|
- fmt.Println(err)
|
|
|
- continue
|
|
|
- }
|
|
|
- if len(output) > 0 {
|
|
|
- fmt.Println(output)
|
|
|
- }
|
|
|
+ maxTasks <- struct{}{}
|
|
|
+ go func(file string) {
|
|
|
+ output, err := Run(binary, append(args, file))
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println(err)
|
|
|
+ } else if len(output) > 0 {
|
|
|
+ fmt.Println(string(output))
|
|
|
+ }
|
|
|
+ <-maxTasks
|
|
|
+ }(file)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -139,7 +139,7 @@ func main() {
|
|
|
goimports = goimportsPath
|
|
|
}
|
|
|
|
|
|
- rawFilesSlice := make([]string, 0)
|
|
|
+ rawFilesSlice := make([]string, 0, 1000)
|
|
|
walkErr := filepath.Walk("./", func(path string, info os.FileInfo, err error) error {
|
|
|
if err != nil {
|
|
|
fmt.Println(err)
|