@@ -65,6 +65,7 @@ func compareFiles(file1, file2 string) (string, error) {
6565func CompareDirectories (dir1 , dir2 string , diffChan chan <- string , errorChan chan <- error , wg * sync.WaitGroup ) {
6666 defer wg .Done ()
6767
68+ var comparisonsCount int
6869 filepath .Walk (dir1 , func (path1 string , info os.FileInfo , err error ) error {
6970 if err != nil {
7071 errorChan <- fmt .Errorf ("error accessing %s: %s" , path1 , err )
@@ -91,6 +92,7 @@ func CompareDirectories(dir1, dir2 string, diffChan chan<- string, errorChan cha
9192 }
9293
9394 if diff != "" {
95+ comparisonsCount ++
9496 diffChan <- fmt .Sprintf ("Differences in file: %s\n %s" , relPath , diff )
9597 }
9698 } else if os .IsNotExist (err ) {
@@ -108,6 +110,7 @@ func CompareDirectories(dir1, dir2 string, diffChan chan<- string, errorChan cha
108110 }
109111
110112 if diff != "" {
113+ comparisonsCount ++
111114 diffChan <- fmt .Sprintf ("Differences in file: %s (present in %s but not in %s)\n %s" , relPath , dir1 , dir2 , diff )
112115 }
113116 } else {
@@ -116,4 +119,6 @@ func CompareDirectories(dir1, dir2 string, diffChan chan<- string, errorChan cha
116119
117120 return nil
118121 })
122+
123+ fmt .Printf ("Total file comparisons: %d\n " , comparisonsCount ) // Print the count at the end
119124}
0 commit comments