How newsand/dedup works
Deduplicator is a Go CLI for finding byte-identical files using BLAKE3, selecting one canonical copy, and reporting or acting on duplicates. The principal workflow runs from CLI command through the pipeline: discover eligible files, compare content, choose canonicals, optionally name copy-unique outputs, plan and validate actions, then execute with dry-run and audit support. README capabilities include report/scan, copy-unique, move, and delete. Pipeline orchestration is excerpted; some internal implementation links are omitted where source excerpts do not show the call.
Main entry points: run.go Pipeline · root.go Commands · runner.go Command runner · delegate.go Compare delegate
Components 21
CLI and configuration
- Commands
internal/cli/root.go - Command runner
internal/cli/runner.go - Configuration
internal/config/loader.go - Program entry
cmd/dedup/main.go
Discovery and comparison
- Pipeline
internal/pipeline/run.go - Filesystem scan
internal/scan/walk.go - File detection
internal/filetype/detect.go - Path filters
internal/scan/filters.go - Compare delegate
internal/compare/delegate.go - Comparator registry
internal/compare/registry.go - File comparators
internal/compare/image_comparator.go - BLAKE3 hashing
internal/hash/blake3.go
Selection and planning
- Canonical selection
internal/canonical/select.go - Output naming
internal/naming/flatten.go - Action planner
internal/actions/plan.go - Safety invariants
internal/actions/invariants.go
Actions and reporting
- Action executor
internal/actions/execute.go - File operations
internal/fs/ops.go - Audit log
internal/report/audit.go - Report output
internal/report/writer.go
Other components
- CLI user
Connections 20
- CLI user → Commands: runs command
README.md - Program entry → Commands: executes
cmd/dedup/main.go - Commands → Command runner: dispatches
internal/cli/root.go - Commands → Configuration: loads settings
internal/cli/root.go - Command runner → Pipeline: starts run
- Pipeline → Filesystem scan: discovers files
internal/pipeline/run.go - Pipeline → File detection: detects types
internal/pipeline/run.go - Pipeline → Path filters: filters paths
internal/pipeline/run.go - Pipeline → Compare delegate: compares files
internal/pipeline/run.go - Compare delegate → Comparator registry: resolves comparator
internal/compare/delegate.go - Compare delegate → File comparators: computes keys
internal/compare/delegate.go - File comparators → BLAKE3 hashing: hashes content
- Pipeline → Canonical selection: selects representatives
internal/pipeline/run.go - Pipeline → Output naming: builds mappings
internal/pipeline/run.go - Pipeline → Action planner: creates plan
internal/pipeline/run.go - Pipeline → Safety invariants: checks plan
internal/pipeline/run.go - Pipeline → Audit log: creates audit log
internal/pipeline/run.go - Pipeline → Action executor: executes plan
internal/pipeline/run.go - Action executor → File operations: mutates files
- Command runner → Report output: formats results