Documentation ¶
Overview ¶
Package equalfile provides facilities for comparing files.
Equalfile is similar to Python's filecmp:
import filecmp if filecmp.cmp(filename1, filename2, shallow=False):
Comparing only two files ¶
In single mode, equalfile compares files byte-by-byte.
import "github.com/udhos/equalfile" // ... cmp := equalfile.New(nil, equalfile.Options{}) // compare using single mode equal, err := cmp.CompareFile("file1", "file2")
Comparing multiple files ¶
In multiple mode, equalfile records files hashes in order to speedup repeated comparisons. You must provide the hashing function.
import "crypto/sha256" import "github.com/udhos/equalfile" // ... cmp := equalfile.NewMultiple(nil, equalfile.Options{}, sha256.New(), true) // enable multiple mode equal, err := cmp.CompareFile("file1", "file2")
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cmp ¶
type Cmp struct { Opt Options // contains filtered or unexported fields }
func NewMultiple ¶
New creates Cmp for multiple comparison mode.
func (*Cmp) CompareFile ¶
CompareFile verifies that files with names path1, path2 have same contents.
func (*Cmp) CompareReader ¶
CompareReader verifies that two readers provide same content.
Reading more than MaxSize will return an error (along with the comparison value up to MaxSize bytes), unless one or both Readers are LimitedReaders, in which case MaxSize is ignored.
type Options ¶
type Options struct { Debug bool // enable debugging to stdout ForceFileRead bool // prevent shortcut at filesystem level (link, pathname, etc) // MaxSize is a safely limit to prevent forever reading from an infinite // reader. If left unset, will default to 1OGBytes. Ignored when // CompareReader() is given one or more io.LimitedReader. MaxSize int64 }