mirror of
https://github.com/weaveworks/scope.git
synced 2026-03-05 11:11:13 +00:00
Changes: - Default diff-printer to hide details (#103) - da4c3ff - Improve logging of http errors (#115) - f5a1710 - Update httpgrpc to match weaveworks/cortex#910 (#117) - 80ff076 - Expose the HTTP server from the server struct. (#118) - 1a7a6b3 - Add HTTP tracing middleware (#119) - d442d08
25 lines
695 B
Go
25 lines
695 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()
|
|
// Set ContinueOnMethod to true if you cannot see a difference and
|
|
// want to look beyond the String() method
|
|
config.ContinueOnMethod = false
|
|
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
|
|
}
|