...

Text file src/github.com/pmezard/go-difflib/README.md

Documentation: github.com/pmezard/go-difflib

     1go-difflib
     2==========
     3
     4THIS PACKAGE IS NO LONGER MAINTAINED.
     5
     6At this point, I have no longer the time nor the interest to work on go-difflib. I apologize for the inconvenience.
     7
     8[![GoDoc](https://godoc.org/github.com/pmezard/go-difflib/difflib?status.svg)](https://godoc.org/github.com/pmezard/go-difflib/difflib)
     9
    10Go-difflib is a partial port of python 3 difflib package. Its main goal
    11was to make unified and context diff available in pure Go, mostly for
    12testing purposes.
    13
    14The following class and functions (and related tests) have be ported:
    15
    16* `SequenceMatcher`
    17* `unified_diff()`
    18* `context_diff()`
    19
    20## Installation
    21
    22```bash
    23$ go get github.com/pmezard/go-difflib/difflib
    24```
    25
    26### Quick Start
    27
    28Diffs are configured with Unified (or ContextDiff) structures, and can
    29be output to an io.Writer or returned as a string.
    30
    31```Go
    32diff := difflib.UnifiedDiff{
    33    A:        difflib.SplitLines("foo\nbar\n"),
    34    B:        difflib.SplitLines("foo\nbaz\n"),
    35    FromFile: "Original",
    36    ToFile:   "Current",
    37    Context:  3,
    38}
    39text, _ := difflib.GetUnifiedDiffString(diff)
    40fmt.Printf(text)
    41```
    42
    43would output:
    44
    45```
    46--- Original
    47+++ Current
    48@@ -1,3 +1,3 @@
    49 foo
    50-bar
    51+baz
    52```
    53

View as plain text