difflib: github.com/aryann/difflib Index | Files | Directories

package difflib

import "github.com/aryann/difflib"

Package difflib provides functionality for computing the difference between two sequences of strings.

Index

Package Files

difflib.go

func Diff Uses

func Diff(seq1, seq2 []string) (diff []DiffRecord)

Diff returns the result of diffing the seq1 and seq2.

func HTMLDiff Uses

func HTMLDiff(seq1, seq2 []string) string

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".

type DeltaType Uses

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.
const (
    Common DeltaType = iota
    LeftOnly
    RightOnly
)

func (DeltaType) String Uses

func (t DeltaType) String() string

String returns a string representation for DeltaType.

type DiffRecord Uses

type DiffRecord struct {
    Payload string
    Delta   DeltaType
}

func (DiffRecord) String Uses

func (d DiffRecord) String() string

String returns a string representation of d. The string is a concatenation of the delta type and the payload.

Directories

PathSynopsis
difflib_serverA demo for difflib.

Package difflib imports 3 packages (graph) and is imported by 32 packages. Updated 2017-07-12. Refresh now. Tools for package owners.