go-diff icon indicating copy to clipboard operation
go-diff copied to clipboard

Diff, match and patch text in Go

Results 31 go-diff issues
Sort by recently updated
recently updated
newest added

``` func TestPatchMakeOutOfRangePanic(t *testing.T) { text1 := ` 1111111111111 000000 ------------- ------ xxxxxxxxxxxxx ------ xxxxxxxxxxxxx ------ xxxxxxxxxxxxx xxxxxx xxxxxxxxxxxxx ...... xxxxxxxxxxxxx 111111 xxxxxxxxxxxxx ?????? xxxxxxxxxxxxx 333333 xxxxxxxxxxxxx 555555 xxxxxxxxxx xxxxx...

https://github.com/sergi/go-diff/commit/db1b095f5e7c905e196ff6bfd56189a41aa76309 introduces a bug in its change from `diffLinesToRunesMunge` to `diffLinesToStringsMunge`. Since each line is represented by 1 or more ascii characters, it's possible for the diffing algorithm to split...

go-diff is currently lacking examples for each exported function and method. This would not only help other users but make the whole project a lot better and complete.

enhancement
Help Wanted

Could go-diff generate an unified diff? Like what git diff or linux diff do? We highly desired to use diff2html to transform diff to html with a unified format

This testcase: ```go func Test(t *testing.T) { src := "a\na: a\na:\n a:\n a\n a: \"a\"\n a: a\n a: \"1\"\n a: 1\n -" dst := "abcde: xxxxx" dmp := New() wSrc,...

I see these: https://godocs.io/github.com/sergi/go-diff/diffmatchpatch#DiffMatchPatch.DiffPrettyHtml https://godocs.io/github.com/sergi/go-diff/diffmatchpatch#DiffMatchPatch.DiffPrettyText how to create a diff without color?

Using the following example: ```go dmp := New() diffs := dmp.DiffMain("a\nb\nc\ndef\ni", "a\ndef\ng\nh\ni", false) ``` Produces the following diffs: ```go diff2 := []Diff{ {Type:DiffEqual, Text:"a\n"}, {Type:DiffDelete, Text:"b\nc\n"}, {Type:DiffEqual, Text:"def"}, {Type:DiffInsert, Text:"\ng\nh"},...

Not sure is this is the best method to do this, but this PR replaces invisible characters in the `Insert/Delete` diffs, so that these characters can be seen and fixed,...

This PR should fix #127 The new code uses same implementation as the Java version: https://github.com/google/diff-match-patch/blob/62f2e689f498f9c92dbc588c58750addec9b1654/java/src/name/fraser/neil/plaintext/diff_match_patch.java#L545 https://github.com/google/diff-match-patch/blob/62f2e689f498f9c92dbc588c58750addec9b1654/java/src/name/fraser/neil/plaintext/diff_match_patch.java#L568