The diffs are plain data; the source and target texts can be reconstructed from them without any pretty printing.
()
| 38 | // The diffs are plain data; the source and target texts can be |
| 39 | // reconstructed from them without any pretty printing. |
| 40 | func ExampleDiffMatchPatch_DiffText1() { |
| 41 | dmp := diffmatchpatch.New() |
| 42 | |
| 43 | diffs := dmp.DiffMain("Hello world.", "Hello goodbye world.", false) |
| 44 | |
| 45 | fmt.Println("source:", dmp.DiffText1(diffs)) |
| 46 | fmt.Println("target:", dmp.DiffText2(diffs)) |
| 47 | |
| 48 | // Output: |
| 49 | // source: Hello world. |
| 50 | // target: Hello goodbye world. |
| 51 | } |
| 52 | |
| 53 | // Diff two texts line by line by reducing each line to a character, |
| 54 | // diffing the reduced texts and expanding the result back to lines. |