Browse Source

reflect: tweak Type.String() to match what encoding/json expects for empty structs

pull/3583/head
Damian Gryski 2 years ago
committed by Ron Evans
parent
commit
6fbe6fa2ae
  1. 5
      src/reflect/type.go

5
src/reflect/type.go

@ -527,8 +527,11 @@ func (t *rawType) String() string {
case Map:
return "map[" + t.key().String() + "]" + t.elem().String()
case Struct:
s := "struct {"
numField := t.NumField()
if numField == 0 {
return "struct {}"
}
s := "struct {"
for i := 0; i < numField; i++ {
f := t.rawField(i)
s += " " + f.Name + " " + f.Type.String()

Loading…
Cancel
Save