github.com/1r0npipe/go-file-find-duplicate@v0.0.0-20210531131222-12a9193c59d9/main.go (about)

     1  package main
     2  
     3  import (
     4  	"flag"
     5  	"fmt"
     6  	"github.com/1r0npipe/go-file-find-duplicate/helper"
     7  	"log"
     8  	"os"
     9  )
    10  
    11  var (
    12  	dirPath = flag.String("dir", "./",
    13  		"Directory to use as root for searching of duplicates, by default current directory")
    14  	del = flag.Bool("delete", false,
    15  		"By default it will just show the duplicates, use \"-delete\" if want to delete")
    16  )
    17  
    18  func main() {
    19  	flag.Parse()
    20  	fileSystem := os.DirFS(*dirPath)
    21  	err := helper.DuplicatesFind(fileSystem, *del)
    22  	if err != nil {
    23  		log.Fatal(err)
    24  	}
    25  	fmt.Printf("Walked through: %d file(-s), found: %d duplicates\n",
    26  		helper.FileCount,
    27  		helper.FilesDuplicates)
    28  }