Skip to content

Commit

Permalink
Make dumper a bit more verbose
Browse files Browse the repository at this point in the history
So it displays differences behind interface that would otherwise go
unnoticed (like string vs []byte).
  • Loading branch information
krnowak committed Aug 12, 2016
1 parent e21dab0 commit 544c349
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions test/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ import (
"github.com/pmezard/go-difflib/difflib"
)

func init() {
spew.Config.SortKeys = true // :\
}

// 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(spew.Sdump(want)),
B: difflib.SplitLines(spew.Sdump(have)),
A: difflib.SplitLines(config.Sdump(want)),
B: difflib.SplitLines(config.Sdump(have)),
FromFile: "want",
ToFile: "have",
Context: 3,
Expand Down

0 comments on commit 544c349

Please sign in to comment.