diff

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidSnapshot is returned when a snapshot file is invalid
	ErrInvalidSnapshot = errors.New("invalid snapshot file")
	// ErrSnapshotNotFound is returned when a snapshot file is not found
	ErrSnapshotNotFound = errors.New("snapshot file not found")
	// ErrOperationCanceled is returned when an operation is canceled
	ErrOperationCanceled = errors.New("operation canceled")
)

Common errors

Functions

func CompareSnapshots

func CompareSnapshots(oldFile, newFile string) ([]string, error)

CompareSnapshots returns a list of differences between two snapshots.

func CompareSnapshotsWithContext

func CompareSnapshotsWithContext(ctx context.Context, oldFile, newFile string) ([]string, error)

CompareSnapshotsWithContext returns a list of differences between two snapshots with context support.

Types

type BloomFilter

type BloomFilter struct {
	// contains filtered or unexported fields
}

BloomFilter is a simple bloom filter implementation

func (*BloomFilter) Add

func (bf *BloomFilter) Add(data []byte)

Add adds an item to the bloom filter

func (*BloomFilter) Contains

func (bf *BloomFilter) Contains(data []byte) bool

Contains checks if an item might be in the bloom filter

type DiffEntry

type DiffEntry struct {
	Type string // "New", "Modified", "Deleted"
	Path string
	// Additional fields for detailed diff information
	OldSize        int64
	NewSize        int64
	OldModTime     int64
	NewModTime     int64
	OldPermissions uint32
	NewPermissions uint32
	HashDiff       bool // True if the hash differs but size and mtime are the same
}

DiffEntry represents a single difference between snapshots

func CompareSnapshotsDetailed

func CompareSnapshotsDetailed(ctx context.Context, oldFile, newFile string) ([]DiffEntry, error)

CompareSnapshotsDetailed returns detailed differences between two snapshots.

func CompareSnapshotsDetailedWithOptions

func CompareSnapshotsDetailedWithOptions(ctx context.Context, oldFile, newFile string, options DiffOptions) ([]DiffEntry, error)

CompareSnapshotsDetailedWithOptions returns detailed differences between two snapshots with custom options.

func (DiffEntry) DetailedString

func (d DiffEntry) DetailedString() string

DetailedString returns a detailed string representation of a DiffEntry

func (DiffEntry) String

func (d DiffEntry) String() string

String returns a string representation of a DiffEntry

type DiffOptions

type DiffOptions struct {
	// Path prefix to filter entries (for partial diffs)
	PathPrefix string
	// Whether to use hash-based diffing
	UseHashDiff bool
	// Number of worker goroutines for parallel diffing (0 = auto)
	Workers int
	// Whether to use bloom filters for quick detection of changes
	UseBloomFilter bool
}

DiffOptions contains options for controlling the diff operation

func DefaultDiffOptions

func DefaultDiffOptions() DiffOptions

DefaultDiffOptions returns the default diff options

Jump to

Keyboard shortcuts

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