MCPcopy Create free account
hub / github.com/prometheus/client_golang / ExampleGetUnifiedDiffString

Function ExampleGetUnifiedDiffString

prometheus/internal/difflib_test.go:117–148  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 3

SplitLinesFunction · 0.85
GetUnifiedDiffStringFunction · 0.85
PrintlnMethod · 0.65

Tested by

no test coverage detected