MCPcopy
hub / github.com/protocolbuffers/protobuf-go / Format

Method Format

encoding/protojson/encode.go:118–125  ·  view source on GitHub ↗

Format formats the message as a string. This method is only intended for human consumption and ignores errors. Do not depend on the output being stable. Its output will change across different builds of your program, even when using the same version of the protobuf module.

(m proto.Message)

Source from the content-addressed store, hash-verified

116// different builds of your program, even when using the same version of the
117// protobuf module.
118func (o MarshalOptions) Format(m proto.Message) string {
119 if m == nil || !m.ProtoReflect().IsValid() {
120 return "<nil>" // invalid syntax, but okay since this is for debugging
121 }
122 o.AllowPartial = true
123 b, _ := o.Marshal(m)
124 return string(b)
125}
126
127// Marshal marshals the given [proto.Message] in the JSON format using options in
128// Do not depend on the output being stable. Its output will change across

Callers 2

marshalTimestampMethod · 0.45
FormatFunction · 0.45

Calls 3

MarshalMethod · 0.95
IsValidMethod · 0.65
ProtoReflectMethod · 0.65

Tested by

no test coverage detected