Преглед изворни кода

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>
Joe Tsai пре 6 година
родитељ
комит
6c30280ad6
1 измењених фајлова са 3 додато и 3 уклоњено
  1. 3 3
      reflect/protoreflect/proto.go

+ 3 - 3
reflect/protoreflect/proto.go

@@ -150,7 +150,7 @@ func (s Syntax) GoString() string {
 	case Proto3:
 		return "Proto3"
 	default:
-		return fmt.Sprintf("<unknown:%d>", s)
+		return fmt.Sprintf("Syntax(%d)", s)
 	}
 }
 
@@ -200,7 +200,7 @@ func (c Cardinality) GoString() string {
 	case Repeated:
 		return "Repeated"
 	default:
-		return fmt.Sprintf("<unknown:%d>", c)
+		return fmt.Sprintf("Cardinality(%d)", c)
 	}
 }
 
@@ -330,7 +330,7 @@ func (k Kind) GoString() string {
 	case GroupKind:
 		return "GroupKind"
 	default:
-		return fmt.Sprintf("<unknown:%d>", k)
+		return fmt.Sprintf("Kind(%d)", k)
 	}
 }