MCPcopy Create free account
hub / github.com/cogentcore/core / ExampleGetUnifiedDiffString

Function ExampleGetUnifiedDiffString

texteditor/difflib/difflib_test.go:115–146  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

113}
114
115func ExampleGetUnifiedDiffString() {
116 a := `one
117two
118three
119four
120fmt.Printf("%s,%T",a,b)`
121 b := `zero
122one
123three
124four`
125 diff := LineDiffParams{
126 A: SplitLines(a),
127 B: SplitLines(b),
128 FromFile: "Original",
129 FromDate: "2005-01-26 23:30:50",
130 ToFile: "Current",
131 ToDate: "2010-04-02 10:20:52",
132 Context: 3,
133 }
134 result, _ := GetUnifiedDiffString(diff)
135 fmt.Println(strings.Replace(result, "\t", " ", -1))
136 // Output:
137 // --- Original 2005-01-26 23:30:50
138 // +++ Current 2010-04-02 10:20:52
139 // @@ -1,5 +1,4 @@
140 // +zero
141 // one
142 // -two
143 // three
144 // four
145 // -fmt.Printf("%s,%T",a,b)
146}
147
148func ExampleGetContextDiffString_fmt() {
149 a := `one

Callers

nothing calls this directly

Calls 3

PrintlnMethod · 0.80
SplitLinesFunction · 0.70
GetUnifiedDiffStringFunction · 0.70

Tested by

no test coverage detected