Skip to content

Commit

Permalink
cmp: invoke stringer on map keys
Browse files Browse the repository at this point in the history
This reverts a change introduced in commit 2940eda where the
cmp package stopped calling the String method when printing map
keys. The motivation for the change is unclear, indeed there was
a pre-existing test that String was called on map keys that the
commit changed.

Fixes google#141
  • Loading branch information
crawshaw committed May 26, 2019
1 parent 6f77996 commit 082b485
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 2 deletions.
2 changes: 1 addition & 1 deletion cmp/compare_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
`,
Expand Down
1 change: 0 additions & 1 deletion cmp/report_reflect.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 082b485

Please sign in to comment.