- Build:
go build -o drift ./cmd/drift - Test:
go test ./...orgo test ./compare -run TestName - Vet:
go vet ./...
drift is a two-layer tool: a comparison engine and an interactive TUI.
Pure-Go diffing logic. Compare(pathA, pathB, mode) returns a *Result with a tree of Nodes representing the comparison. Detail(result, node) produces the detailed diff for a single node.
Supported modes: tree (directories/archives), binary (Mach-O), plist, text. Mode is auto-detected from inputs.
Key files:
compare.go- entry point, mode detection, tree comparisondirectory.go- directory walking and tree buildingarchive.go- archive extraction (zip, tar, tar.gz, tar.bz2)binary.go- Mach-O analysis via nm/size/otoolplist.go- plist conversion via plutiltext.go- line-by-line unified difftypes.go-Result,Node,DetailResulttypeshash.go- content hashing for change detection
Bubbletea-based interactive terminal UI. Three-tier component model:
- App (
app.go) - root model, layout, keyboard dispatch - Components (
tree.go,detail.go,search.go,overlay.go,alert.go) - stateful sub-models - Views (
view_*.go,summary.go,render.go) - pure render functions, no state
styles.go- all lipgloss styleshelp.go- keybinding definitionscomponents.go- detail content builder
cmd/drift/main.go- CLI struct, kong parser,run()method
- Views are pure functions:
func renderX(width int, data T) string - Components own state and implement
Update/View - Use lipgloss for all styling - no raw ANSI