From 1ffc47f77ec7d263812c32c7a940ce8fb818327f Mon Sep 17 00:00:00 2001 From: Joe Tsai Date: Mon, 24 Jun 2019 16:03:52 -0700 Subject: [PATCH] reflect/protoreflect: print unknown number in String methods Preserving the unknown enum in the String method helps errors produced by reflect/protodesc be more informative. Change-Id: I8efb09cb3c744bf4483b310053df7686da540387 Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/183699 Reviewed-by: Damien Neil --- reflect/protoreflect/proto.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/reflect/protoreflect/proto.go b/reflect/protoreflect/proto.go index fef5145e..1288b06d 100644 --- a/reflect/protoreflect/proto.go +++ b/reflect/protoreflect/proto.go @@ -27,6 +27,7 @@ package protoreflect import ( + "fmt" "regexp" "strings" @@ -69,7 +70,7 @@ func (s Syntax) String() string { case Proto3: return "proto3" default: - return "" + return fmt.Sprintf("", s) } } @@ -81,7 +82,7 @@ func (s Syntax) GoString() string { case Proto3: return "Proto3" default: - return "" + return fmt.Sprintf("", s) } } @@ -117,7 +118,7 @@ func (c Cardinality) String() string { case Repeated: return "repeated" default: - return "" + return fmt.Sprintf("", c) } } @@ -131,7 +132,7 @@ func (c Cardinality) GoString() string { case Repeated: return "Repeated" default: - return "" + return fmt.Sprintf("", c) } } @@ -217,7 +218,7 @@ func (k Kind) String() string { case GroupKind: return "group" default: - return "" + return fmt.Sprintf("", k) } } @@ -261,7 +262,7 @@ func (k Kind) GoString() string { case GroupKind: return "GroupKind" default: - return "" + return fmt.Sprintf("", k) } }