Is there a good way to get a human readable string representation of protobuf objects in golang? Something equivalent to https://developers.google.com/protocol-buffers/docs/reference/cpp/google.protobuf.message#Message.DebugString?
I am using https://github.com/golang/protobuf.
There are two requirements for the full process. protoc binary installed on your path go get -u github.com/gogo/protobuf/... You can generate the proto files, the marshal/unmarshal and the rest of protobuf stuff for your Go types, the RPC client and server interface and the RPC server implementation for your packages.
func (pb *ProgressBar) Prefix(prefix string) *ProgressBar.
Protobuf, on the other hand, usually compresses data better and has built-in protocol documentation via the schema. Another major factor is the CPU performance — the time it takes for the library to serialize and deserializes a message. In this post, we want to compare just the performance in JavaScript.
I believe you're looking for proto.MarshalTextString.
p := &example.Test{
Label: proto.String("this"),
Reps: []int64{4, 3, 2, 1},
InnerTest: &example.Test_InnerTest{
InnerLabel: proto.String("is the end"),
},
}
fmt.Println(proto.MarshalTextString(p))
You can see an example in the Go package test.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With