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

Function ExampleGetUnifiedDiffString

texteditor/difflib/bytes/bytes_test.go:132–163  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

130}
131
132func ExampleGetUnifiedDiffString() {
133 a := `one
134two
135three
136four
137fmt.Printf("%s,%T",a,b)`
138 b := `zero
139one
140three
141four`
142 diff := UnifiedDiff{
143 A: SplitLines([]byte(a)),
144 B: SplitLines([]byte(b)),
145 FromFile: "Original",
146 FromDate: "2005-01-26 23:30:50",
147 ToFile: "Current",
148 ToDate: "2010-04-02 10:20:52",
149 Context: 3,
150 }
151 result, _ := GetUnifiedDiffString(diff)
152 fmt.Println(strings.Replace(string(result), "\t", " ", -1))
153 // Output:
154 // --- Original 2005-01-26 23:30:50
155 // +++ Current 2010-04-02 10:20:52
156 // @@ -1,5 +1,4 @@
157 // +zero
158 // one
159 // -two
160 // three
161 // four
162 // -fmt.Printf("%s,%T",a,b)
163}
164
165func ExampleGetContextDiffString_fmt() {
166 a := `one

Callers

nothing calls this directly

Calls 3

PrintlnMethod · 0.80
SplitLinesFunction · 0.70
GetUnifiedDiffStringFunction · 0.70

Tested by

no test coverage detected