Debian Codegraph @

README.md

raw symbols SCIP
1 go-difflib
2 ==========
3
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 For these reasons I have taken over maintenance and further development of the
8 project.
9
10 [![GoDoc](https://godoc.org/github.com/ianbruene/go-difflib/difflib?status.svg)](https://godoc.org/github.com/ianbruene/go-difflib/difflib)
11
12 Go-difflib is an as yet partial port of python 3's difflib package.
13
14 The following publicly visible classes and functions have been ported:
15
16 * `SequenceMatcher`
17 * `Differ`
18 * `unified_diff()`
19 * `context_diff()`
20
21 ## Installation
22
23 ```bash
24 $ go get github.com/ianbruene/go-difflib/difflib
25 ```
26
27 ### UnifiedDiff Quick Start
28
29 Diffs are configured with Unified (or ContextDiff) structures, and can
30 be output to an io.Writer or returned as a string.
31
32 ```Go
33 diff := difflib.LineDiffParams{
34 A: difflib.SplitLines("foo\nbar\n"),
35 B: difflib.SplitLines("foo\nbaz\n"),
36 FromFile: "Original",
37 ToFile: "Current",
38 Context: 3,
39 }
40 text, _ := difflib.GetUnifiedDiffString(diff)
41 fmt.Printf(text)
42 ```
43
44 would output:
45
46 ```
47 --- Original
48 +++ Current
49 @@ -1,3 +1,3 @@
50 foo
51 -bar
52 +baz
53 ```
54
55 ### Differ Quick Start
56
57 Differ has been implemented primarily for the Compare() function at this time.
58
59 ```Go
60 diff := difflib.NewDiffer()
61 out, err := diff.Compare(
62 []string{"foo\n", "bar\n", "baz\n"},
63 []string{"foo\n", "bar1\n", "asdf\n", "baz\n"})
64 ```
65
66 would output:
67
68 ```
69 foo
70 - bar
71 + bar1
72 ? +
73 + asdf
74 baz
75 ```