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

This commit is contained in:
Damian Gryski
2023-03-18 22:55:02 -07:00
committed by Ron Evans
parent 24b4dc31a4
commit 6fbe6fa2ae
+4 -1
View File
@@ -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()