Documentation
¶
Overview ¶
Package diff compares two CSV files as tables rather than as text.
The comparison runs in two passes. The first pass walks the old file and records, for every row, its key, a 128-bit fingerprint of the compared columns, and the byte offset where the row starts. The second pass streams the new file and looks each row up in that index. Full row text is only ever pulled back off disk for rows that turn out to differ, so memory grows with the number of rows rather than with the width of the file.
Index ¶
Constants ¶
const ( KeyExplicit = "explicit" KeyAuto = "auto-detected" KeyFullRow = "full-row" )
How the matching key was chosen.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Change ¶
type Change struct {
Column string `json:"column"`
Old string `json:"old"`
New string `json:"new"`
}
Change is one differing cell within a modified row.
type FileInfo ¶
type FileInfo struct {
Name string `json:"name"`
Encoding string `json:"encoding"`
Delimiter string `json:"delimiter"`
Rows int `json:"rows"`
}
FileInfo describes one side of the comparison.
type Moved ¶
Moved is a row whose content is identical but whose position shifted. The values are re-read from the old file so that exports carry the whole row rather than just a key.
type Options ¶
type Options struct {
Key []string // explicit key columns; empty means decide automatically
FullRow bool // force whole-row matching, skipping key detection
IgnoreColumns []string // columns excluded from the comparison
Strict bool // compare values byte for byte and treat column order as significant
NoHeader bool // treat the first row as data and name columns c1, c2, ...
ShowReordered bool // report rows whose content is unchanged but whose position moved
}
Options controls how two files are matched and compared.
type Result ¶
type Result struct {
Old, New FileInfo
Columns []string // union of both headers, in display order
Compared []string // columns actually used for the comparison
Ignored []string
AddedColumns []string
RemovedColumns []string
OrderChanged bool
Key []string
KeySource string
Added []Row
Removed []Row
Modified []Modified
Moved []Moved
Unchanged int
Warnings []string
}
Result is the full comparison.
func (*Result) HasChanges ¶
HasChanges reports whether anything the caller asked about actually differs.