reflect/protoreflect: emit valid Go from GoString
Rather than using the <unknown:%d> syntax for GoString,
emit something similar to TypeName(%d),
which is functionally equivalent to casting the integer
to the specified type.
Change-Id: Ibf4bd680d1672fcaba9022fb6bd03bbfe249b8b7
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/191580
Reviewed-by: Herbie Ong <herbie@google.com>
diff --git a/reflect/protoreflect/proto.go b/reflect/protoreflect/proto.go
index ed7e74d..7152a4a 100644
--- a/reflect/protoreflect/proto.go
+++ b/reflect/protoreflect/proto.go
@@ -150,7 +150,7 @@
case Proto3:
return "Proto3"
default:
- return fmt.Sprintf("<unknown:%d>", s)
+ return fmt.Sprintf("Syntax(%d)", s)
}
}
@@ -200,7 +200,7 @@
case Repeated:
return "Repeated"
default:
- return fmt.Sprintf("<unknown:%d>", c)
+ return fmt.Sprintf("Cardinality(%d)", c)
}
}
@@ -330,7 +330,7 @@
case GroupKind:
return "GroupKind"
default:
- return fmt.Sprintf("<unknown:%d>", k)
+ return fmt.Sprintf("Kind(%d)", k)
}
}