Documentation ¶
Index ¶
- Constants
- type Diff
- type Diffs
- func (pDiffs *Diffs) CleanupEfficiency(editCost int) (diffs Diffs)
- func (pDiffs *Diffs) CleanupMerge() (diffs Diffs)
- func (pdiffs *Diffs) CleanupSemantic() (diffs Diffs)
- func (pDiffs *Diffs) CleanupSemanticLossless() (diffs Diffs)
- func (diffs Diffs) Levenshtein() (levenshtein int)
- func (diffs Diffs) PrettyHTML() (s string)
- func (diffs Diffs) Text1() (source string)
- func (diffs Diffs) Text2() (dest string)
- func (diffs Diffs) XIndex(loc1 int) (loc2 int)
Constants ¶
const ( DefaultEditCost = 4 DefaultTimeout = time.Second NoTimeout = -1 )
const ( Equal = '=' Insert = '+' Delete = '-' )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Diffs ¶
type Diffs []Diff
The data structure representing a diff is a slice of Diff objects:
[]Diff{ {Delete, "Hello"}, {Insert, "Goodbye"}, {Equal, " world."}}
which means: delete "Hello", add "Goodbye" and keep " world."
func DiffMain ¶
Find the differences between two texts. If checkLines is false, then don't run a line-level diff first to identify the changed areas. If it is true, then run a faster slightly less optimal diff.
If timeout is NoTimeout, or -1, it timeout will be inactive. If it is 0, DefaultTimeout will be used.
func (*Diffs) CleanupEfficiency ¶
Reduce the number of edits by eliminating operationally trivial equalities.
func (*Diffs) CleanupMerge ¶
Reorder and merge like edit sections. Merge equalities. Any edit section can move as long as it doesn't cross an equality.
func (*Diffs) CleanupSemantic ¶
Reduce the number of edits by eliminating semantically trivial equalities.
func (*Diffs) CleanupSemanticLossless ¶
Look for single edits surrounded on both sides by equalities which can be shifted sideways to align the edit to a word boundary.
e.g.: The c<ins>at c</ins>ame. -> The <ins>cat </ins>came.
func (Diffs) Levenshtein ¶
Compute the Levenshtein distance – the number of inserted, deleted or substituted characters.
func (Diffs) PrettyHTML ¶
Convert a Diff list into a pretty HTML report.