mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-10 22:13:39 +00:00
reflect: tweak Type.String() to match what encoding/json expects for empty structs
This commit is contained in:
+4
-1
@@ -527,8 +527,11 @@ func (t *rawType) String() string {
|
|||||||
case Map:
|
case Map:
|
||||||
return "map[" + t.key().String() + "]" + t.elem().String()
|
return "map[" + t.key().String() + "]" + t.elem().String()
|
||||||
case Struct:
|
case Struct:
|
||||||
s := "struct {"
|
|
||||||
numField := t.NumField()
|
numField := t.NumField()
|
||||||
|
if numField == 0 {
|
||||||
|
return "struct {}"
|
||||||
|
}
|
||||||
|
s := "struct {"
|
||||||
for i := 0; i < numField; i++ {
|
for i := 0; i < numField; i++ {
|
||||||
f := t.rawField(i)
|
f := t.rawField(i)
|
||||||
s += " " + f.Name + " " + f.Type.String()
|
s += " " + f.Name + " " + f.Type.String()
|
||||||
|
|||||||
Reference in New Issue
Block a user