fileduplicate

package module
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 7, 2023 License: MIT Imports: 7 Imported by: 0

README

File Duplicate

Go Reference

Features

  • Find duplicate files
  • Command line ready to use
  • Library that can be integrated in a project

Usage

# Local build
make build
./build/file-duplicate -h

# Remote install
go install github.com/pierrre/file-duplicate/cmd/file-duplicate@latest

# Module install
go get github.com/pierrre/file-duplicate@latest

Implementation

  • Walk the filesystems
  • Group files by identical size
  • Compute the SHA256 hash of same size files
  • Files with same hash are duplicates

Documentation

Overview

Package fileduplicate provides utilities to find duplicate files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

func Get(ctx context.Context, optfs ...Option) ([][]*File, error)

Get returns the duplicated [Files].

func Scan

func Scan(ctx context.Context, onDuplicates func([]*File), optfs ...Option) error

Scan scans for duplicated [Files].

The onDuplicates function is called for each duplicated file.

Types

type File

type File struct {
	// FSIndex is the index of the filesystem where the file is located.
	FSIndex int
	// Path is the path of the file in the filesystem.
	Path string
}

File represents a file.

type Option

type Option func(*options)

Option represents an option.

func WithErrorHandler

func WithErrorHandler(f func(context.Context, error)) Option

WithErrorHandler is an Option that defines the error handler.

If it is defined, the error handler is called for each error, otherwise the error is returned.

func WithFSs

func WithFSs(fsyss []fs.FS) Option

WithFSs is an Option that defines the filesystems to scan.

func WithMinSize

func WithMinSize(minSize int64) Option

WithMinSize is an Option that defines the minimum file size to consider.

Directories

Path Synopsis
cmd
file-duplicate
Package file-duplicate provides a command line tool to find duplicate files.
Package file-duplicate provides a command line tool to find duplicate files.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL