Documentation ¶
Overview ¶
Package difflib provides functionality for computing the difference between two sequences of strings.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HTMLDiff ¶
HTMLDiff returns the results of diffing seq1 and seq2 as an HTML string. The resulting HTML is a table without the opening and closing table tags. Each table row represents a DiffRecord. The first and last columns contain the "line numbers" for seq1 and seq2, respectively (the function assumes that seq1 and seq2 represent the lines in a file). The second and third columns contain the actual file contents.
The cells that contain line numbers are decorated with the class "line-num". The cells that contain deleted elements are decorated with "deleted" and the cells that contain added elements are decorated with "added".
Types ¶
type DeltaType ¶
type DeltaType int
DeltaType describes the relationship of elements in two sequences. The following table provides a summary:
Constant Code Meaning ---------- ------ --------------------------------------- Common " " The element occurs in both sequences. LeftOnly "-" The element is unique to sequence 1. RightOnly "+" The element is unique to sequence 2.
type DiffRecord ¶
func Diff ¶
func Diff(seq1, seq2 []string) (diff []DiffRecord)
Diff returns the result of diffing the seq1 and seq2.
func (DiffRecord) String ¶
func (d DiffRecord) String() string
String returns a string representation of d. The string is a concatenation of the delta type and the payload.