CreatePatch computes a compact patch that transforms oldText into newText. The patch can be applied with ApplyPatch to recover newText from oldText.
(oldText, newText string)
| 14 | // CreatePatch computes a compact patch that transforms oldText into newText. |
| 15 | // The patch can be applied with ApplyPatch to recover newText from oldText. |
| 16 | func CreatePatch(oldText, newText string) string { |
| 17 | diffs := dmp.DiffMain(oldText, newText, true) |
| 18 | patches := dmp.PatchMake(oldText, diffs) |
| 19 | return dmp.PatchToText(patches) |
| 20 | } |
| 21 | |
| 22 | // ApplyPatch applies a patch to baseText to produce the target text. |
| 23 | // Returns an error if the patch cannot be applied cleanly. |
no outgoing calls