Documentation
¶
Overview ¶
Package diff computes line diffs and formats them as unified diffs.
Lines compares two lists of lines with patience diff: lines that occur exactly once on both sides anchor the comparison, and the regions between anchors are compared again. A region without such lines is compared with Myers' algorithm, which finds a shortest edit script, in linear space. Patience diff keeps unrelated changes apart on the unique lines of code, such as declarations, and bounds the work on large files: a region too large for Myers' algorithm is replaced as a whole.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SplitLines ¶
SplitLines splits text into lines that keep their "\n" terminator; the last line has none if the text does not end with a newline.
func Unified ¶
Unified returns the unified diff that turns old into new, with up to context unchanged lines around each change, or "" if they are equal. The header names the sides oldName and newName, for example "a/main.go" and "b/main.go", or "/dev/null" for a side that does not exist. A last line without a newline is marked as in diff and git.