$ go test -race ./...
# gojsondiff/jd
jd/main.go:42:4: Println arg list ends with redundant newline
# gojsondiff/jp
jp/main.go:24:4: Println arg list ends with redundant newline
ok gojsondiff 1.919s
ok gojsondiff/formatter 1.104s
The code is quite complex, so I may be missing some obvious things, so please let me know if that's the case!
I'm also introducing go.mod in the same PR, which is resulting in a giant bulk of changes. The actual code changes are very minimal and all under the gojsondiff.go file.
As highlighted in various issues (https://github.com/yudai/gojsondiff/issues/24, https://github.com/yudai/gojsondiff/issues/30), the library is currently failing at computing correct and reliable diffs for arrays, and more specifically whenever the size of the "left" array is less than the "right" one:
case 1: len(left) < len(right) (bogus diffs)
case 1 (continuation): len(left) < len(right) (unreliable diffs)
case 2: len(left) == len(right) (OK)
case 3: len(left) > len(right) (diffs are OK, but there is a lingering duplicate element at the bottom of the array)
Both issues highlighted in case 1 are the most serious ones, while the one in case 3 is mostly visually confusing.
I believe the cause of these issues are two:
maybe
matrixes here, you are missing the last element of each row/columnWhat I'm proposing here is a simple fix for the (1) and to use
strutil
to calculate the similarity for (2).Changes don't break current test cases:
The code is quite complex, so I may be missing some obvious things, so please let me know if that's the case!
I'm also introducing
go.mod
in the same PR, which is resulting in a giant bulk of changes. The actual code changes are very minimal and all under thegojsondiff.go
file.