aboutsummaryrefslogtreecommitdiff
path: root/cmp
diff options
context:
space:
mode:
authorDavid Crawshaw <crawshaw@golang.org>2019-05-27 12:30:12 -0400
committerJoe Tsai <joetsai@digital-static.net>2019-05-27 09:30:12 -0700
commit917e382dab80060fd1f094402bfbb5137ec3c4ff (patch)
treea59eb016822aaae5ce56470024341019ee656af0 /cmp
parent6f77996f0c42f7b84e5a2b252227263f93432e9b (diff)
downloadgo-cmp-917e382dab80060fd1f094402bfbb5137ec3c4ff.tar.gz
Invoke String when formatting map keys (#142)
This reverts a change introduced in commit 2940eda701 where cmp stopped calling the String method when printing map keys. Fixes #141
Diffstat (limited to 'cmp')
-rw-r--r--cmp/compare_test.go2
-rw-r--r--cmp/report_reflect.go1
2 files changed, 1 insertions, 2 deletions
diff --git a/cmp/compare_test.go b/cmp/compare_test.go
index ad03f36..ed46488 100644
--- a/cmp/compare_test.go
+++ b/cmp/compare_test.go
@@ -518,7 +518,7 @@ func comparerTests() []test {
y: map[*pb.Stringer]*pb.Stringer(nil),
wantDiff: `
map[*testprotos.Stringer]*testprotos.Stringer(
-- {⟪0xdeadf00f⟫: s"world"},
+- {s"hello": s"world"},
+ nil,
)
`,
diff --git a/cmp/report_reflect.go b/cmp/report_reflect.go
index 5521c60..2761b62 100644
--- a/cmp/report_reflect.go
+++ b/cmp/report_reflect.go
@@ -208,7 +208,6 @@ func (opts formatOptions) FormatValue(v reflect.Value, m visitedPointers) (out t
func formatMapKey(v reflect.Value) string {
var opts formatOptions
opts.TypeMode = elideType
- opts.AvoidStringer = true
opts.ShallowPointers = true
s := opts.FormatValue(v, visitedPointers{}).String()
return strings.TrimSpace(s)