You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The result is non-deterministic and the last element of path changes, here from tTest1Samp to wins: [{"leftValue":1.807738195866628,"path":[0,"result","analysis","wins"]},{"path":[0,"result","tTest1Samp"],"rightValue":"(1.807738195866628,)"}]
Any leads?
I narrowed down the problem to lines 79,89 for key := range map1 { _, keyInMap2 := map2[key] if keyInMap2 { diff = append(diff, compareObject(append(path, key), map1[key], map2[key])...) } else { diff = append(diff, map[string]interface{}{ "path": append(path, key), "leftValue": map1[key], }) } }
path is maintaining a reference to key instead of a value and as key iterates through map1, the value of a stored append(path, key) changes over the iterations. Even if I try something like new_key := string(key) "path": append(path, new_key)
the mutation still occurs.
From the string and append documentations it doesn't seem like this should be the case, so that's why there may be an underlying issue in go.
The text was updated successfully, but these errors were encountered:
As a sidenote, I recommend running go vet on the codebase:
.\json-diff.go:129:48: conversion from Kind (uint) to string yields a string of one rune, not a string of digits (did you mean fmt.Sprint(x)?)
.\json-diff.go:129:76: conversion from Kind (uint) to string yields a string of one rune, not a string of digits (did you mean fmt.Sprint(x)?)
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
In: https://github.com/tyleradams/json-toolkit/tree/master/debug
Ran:
go run ../json-diff.go o.json u.json
What did you expect to see?
[{"leftValue":1.807738195866628,"path":[0,"result","analysis","tTest1Samp":[0,"result","tTest1Samp"],"rightValue":"(1.807738195866628,)"}]
What did you see instead?
The result is non-deterministic and the last element of path changes, here from tTest1Samp to wins:
[{"leftValue":1.807738195866628,"path":[0,"result","analysis","wins"]},{"path":[0,"result","tTest1Samp"],"rightValue":"(1.807738195866628,)"}]
Any leads?
I narrowed down the problem to lines 79,89
for key := range map1 { _, keyInMap2 := map2[key] if keyInMap2 { diff = append(diff, compareObject(append(path, key), map1[key], map2[key])...) } else { diff = append(diff, map[string]interface{}{ "path": append(path, key), "leftValue": map1[key], }) } }
path is maintaining a reference to key instead of a value and as key iterates through map1, the value of a stored append(path, key) changes over the iterations. Even if I try something like
new_key := string(key) "path": append(path, new_key)
the mutation still occurs.
From the string and append documentations it doesn't seem like this should be the case, so that's why there may be an underlying issue in go.
The text was updated successfully, but these errors were encountered: