mirror of
https://github.com/protocolbuffers/protobuf-go.git
synced 2025-01-01 11:58:21 +00:00
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 <dneil@google.com>
This commit is contained in:
parent
2fc306a8e3
commit
1ffc47f77e
@ -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 "<unknown>"
|
||||
return fmt.Sprintf("<unknown:%d>", s)
|
||||
}
|
||||
}
|
||||
|
||||
@ -81,7 +82,7 @@ func (s Syntax) GoString() string {
|
||||
case Proto3:
|
||||
return "Proto3"
|
||||
default:
|
||||
return "<unknown>"
|
||||
return fmt.Sprintf("<unknown:%d>", s)
|
||||
}
|
||||
}
|
||||
|
||||
@ -117,7 +118,7 @@ func (c Cardinality) String() string {
|
||||
case Repeated:
|
||||
return "repeated"
|
||||
default:
|
||||
return "<unknown>"
|
||||
return fmt.Sprintf("<unknown:%d>", c)
|
||||
}
|
||||
}
|
||||
|
||||
@ -131,7 +132,7 @@ func (c Cardinality) GoString() string {
|
||||
case Repeated:
|
||||
return "Repeated"
|
||||
default:
|
||||
return "<unknown>"
|
||||
return fmt.Sprintf("<unknown:%d>", c)
|
||||
}
|
||||
}
|
||||
|
||||
@ -217,7 +218,7 @@ func (k Kind) String() string {
|
||||
case GroupKind:
|
||||
return "group"
|
||||
default:
|
||||
return "<unknown>"
|
||||
return fmt.Sprintf("<unknown:%d>", k)
|
||||
}
|
||||
}
|
||||
|
||||
@ -261,7 +262,7 @@ func (k Kind) GoString() string {
|
||||
case GroupKind:
|
||||
return "GroupKind"
|
||||
default:
|
||||
return "<unknown>"
|
||||
return fmt.Sprintf("<unknown:%d>", k)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user