11go-difflib
22==========
33
4- [ ![ Build Status] ( https://travis-ci.org/pmezard/go-difflib.png?branch=master )] ( https://travis-ci.org/pmezard/go-difflib )
5- [ ![ GoDoc] ( https://godoc.org/github.com/pmezard/go-difflib/difflib?status.svg )] ( https://godoc.org/github.com/pmezard/go-difflib/difflib )
4+ The previous owner of this project (pmezard) did not have the time to continue
5+ working on it. Additionally I (ianbruene) needed additional ported features.
6+
7+ I have taken over maintenance and further development of the project
8+
9+ [ ![ GoDoc] ( https://godoc.org/github.com/ianbruene/go-difflib/difflib?status.svg )] ( https://godoc.org/github.com/ianbruene/go-difflib/difflib )
610
711Go-difflib is a partial port of python 3 difflib package. Its main goal
8- was to make unified and context diff available in pure Go, mostly for
9- testing purposes.
12+ is to make unified and context diff available in pure Go.
1013
1114The following class and functions (and related tests) have be ported:
1215
1316* ` SequenceMatcher `
17+ * ` Differ `
1418* ` unified_diff() `
1519* ` context_diff() `
1620
1721## Installation
1822
1923``` bash
20- $ go get github.com/pmezard /go-difflib/difflib
24+ $ go get github.com/ianbruene /go-difflib/difflib
2125```
2226
23- ### Quick Start
27+ ### UnifiedDiff Quick Start
2428
2529Diffs are configured with Unified (or ContextDiff) structures, and can
2630be output to an io.Writer or returned as a string.
2731
2832``` Go
29- diff := UnifiedDiff {
33+ diff := difflib. UnifiedDiff {
3034 A : difflib.SplitLines (" foo\n bar\n " ),
3135 B : difflib.SplitLines (" foo\n baz\n " ),
3236 FromFile : " Original" ,
3337 ToFile : " Current" ,
3438 Context : 3 ,
3539}
36- text , _ := GetUnifiedDiffString (diff)
40+ text , _ := difflib. GetUnifiedDiffString (diff)
3741fmt.Printf (text)
3842```
3943
@@ -48,3 +52,23 @@ would output:
4852+baz
4953```
5054
55+ ### Differ Quick Start
56+
57+ Differ has been implemented primarily for the Compare() function at this time.
58+
59+ ``` Go
60+ out , err := diff.Compare (
61+ []string {" foo\n " , " bar\n " , " baz\n " },
62+ []string {" foo\n " , " bar1\n " , " asdf\n " , " baz\n " })
63+ ```
64+
65+ would output:
66+
67+ ```
68+ foo
69+ - bar
70+ + bar1
71+ ? +
72+ + asdf
73+ baz
74+ ```
0 commit comments