Files
weave-scope/test/diff.go
Krzesimir Nowak 1f222b9156 Make dumper a bit more verbose
So it displays differences behind interface that would otherwise go
unnoticed (like string vs []byte).
2016-08-12 17:03:42 +02:00

23 lines
582 B
Go

package test
import (
"github.com/davecgh/go-spew/spew"
"github.com/pmezard/go-difflib/difflib"
)
// Diff diffs two arbitrary data structures, giving human-readable output.
func Diff(want, have interface{}) string {
config := spew.NewDefaultConfig()
config.ContinueOnMethod = true
config.SortKeys = true
config.SpewKeys = true
text, _ := difflib.GetUnifiedDiffString(difflib.UnifiedDiff{
A: difflib.SplitLines(config.Sdump(want)),
B: difflib.SplitLines(config.Sdump(have)),
FromFile: "want",
ToFile: "have",
Context: 3,
})
return "\n" + text
}