Documentation
¶
Overview ¶
Package diff compares sequences: the lines of two texts, or the words of two lines. It finds the changes with the histogram algorithm of git (xhistogram.c), which anchors on lines that occur rarely and so keeps the matches people expect in source code, falling back to Myers's O(ND) algorithm, with xdiff's cost limit, where every line repeats too often. Groups of changed lines are then slid to start and end where blank lines and indentation make them read as whole blocks, with git's indent heuristic.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Hunk ¶
type Hunk struct{ A0, A1, B0, B1 int }
Hunk is a change: the elements A0 to A1 of the old sequence replaced by B0 to B1 of the new one. A0 == A1 is an insertion before A0, B0 == B1 a deletion.
type Range ¶
type Range struct{ Start, End int }
Range is a range of bytes, Start to End.
func Words ¶
Words compares two texts word by word, as review tools highlight what changed within lines: words (letters, digits and underscores), runs of whitespace and other characters one at a time. It returns the byte ranges of a and b that changed, joined across the whitespace between them, and how much of the two texts stayed the same, from 0 to 1, by their bytes.