diff --git a/SynchRoGazer.go b/SynchRoGazer.go index e8010a2..ce75654 100644 --- a/SynchRoGazer.go +++ b/SynchRoGazer.go @@ -235,6 +235,8 @@ func main() { var taskCount int64 + var entries int64 + scanner := bufio.NewScanner(os.Stdin) defer os.Stdin.Close() @@ -261,6 +263,7 @@ func main() { defer atomic.AddInt64(&taskCount, -1) for scanner.Scan() { path := scanner.Text() + atomic.AddInt64(&entries, 1) atomic.AddInt64(&taskCount, 1) go func() { @@ -279,8 +282,11 @@ func main() { //Already print before finishing, use atomic ints instead of a WaitGroup for atomic.LoadInt64(&taskCount) > 0 { - result := <-resultChannel - PrintHashFileResult(&result, *outputFormat, pgSettings) + if atomic.LoadInt64(&entries) > 0 { + atomic.AddInt64(&entries, -1) + result := <-resultChannel + PrintHashFileResult(&result, *outputFormat, pgSettings) + } } close(resultChannel)