You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have some Protobuf/gRPC generated types that I would like to pretty print using spew.
Some types, like enums, have String() methods generated that produce nice, readable output, for an example, see DevStatusReply_Status in the code below. For these types I prefer spew calling String() instead of formatting by itself.
Some types, structs like DevStatusReply_StatusDetails below , have a generated String() method that produces terses output. For these types I would rather have spew handle the printing by itself.
Using ConfigState.DisableMethods I can turn off and on whether spew calls the String() method, but I cannot discern between calling String() for the enums and spew pretty printing for the structs.
Is there a way I can control more finely which String()methods get called? Is there a way to work around this, except duplicating spew's code in my own program?
Code:
type DevStatusReply struct {
Status DevStatusReply_Status `protobuf:"varint,4,opt,name=...`
Details *DevStatusReply_StatusDetails `protobuf:"bytes,8,opt,name=..."`
}
type DevStatusReply_Status int32
const (
DevStatusReply_INVALID_STATUS DevStatusReply_Status = 0
DevStatusReply_IDLE DevStatusReply_Status = 1
// and so on...
)
// prints nice string representation of enum
func (s DevStatusReply_Status) String() string { ... }
type DevStatusReply_StatusDetails struct {
...
}
// prints unwanted string representation of struct
func (x *DevStatusReply_StatusDetails) String() { ... }
The text was updated successfully, but these errors were encountered:
Might want to report this to the gRPC developers so the protoc plugin can produce better output. It should be implementing GoStringer for a string representation of the Go syntax, not String.
I have some Protobuf/gRPC generated types that I would like to pretty print using spew.
Some types, like enums, have
String()
methods generated that produce nice, readable output, for an example, seeDevStatusReply_Status
in the code below. For these types I prefer spew callingString()
instead of formatting by itself.Some types, structs like
DevStatusReply_StatusDetails
below , have a generatedString()
method that produces terses output. For these types I would rather have spew handle the printing by itself.Using
ConfigState.DisableMethods
I can turn off and on whether spew calls theString()
method, but I cannot discern between callingString()
for the enums and spew pretty printing for the structs.Is there a way I can control more finely which
String()
methods get called? Is there a way to work around this, except duplicating spew's code in my own program?Code:
The text was updated successfully, but these errors were encountered: