Documentation ¶
Index ¶
Constants ¶
const ( Any_TypeUrl_field_number protoreflect.FieldNumber = 1 Any_Value_field_number protoreflect.FieldNumber = 2 Any_AtType_field_number protoreflect.FieldNumber = 3 )
Field numbers for Any.
Variables ¶
This section is empty.
Functions ¶
func Format ¶
Format formats the message as a multiline string. This function is only intended for human consumption and ignores errors. Do not depend on the output being stable. It may change over time across different versions of the program.
func Marshal ¶
Marshal writes the given proto.Message in JSON format using default options. Do not depend on the output being stable. It may change over time across different versions of the program.
func SetNewDecoder ¶
func SetNewDecoder(f codec.NewDecoderFun)
func SetNewEncoder ¶
func SetNewEncoder(f codec.NewEncoderFun)
Types ¶
type MarshalOptions ¶
type MarshalOptions struct { pragma.NoUnkeyedLiterals // Multiline specifies whether the marshaler should format the output in // indented-form with every textual element on a new line. // If Indent is an empty string, then an arbitrary indent is chosen. Multiline bool // Indent specifies the set of indentation characters to use in a multiline // formatted output such that every entry is preceded by Indent and // terminated by a newline. If non-empty, then Multiline is treated as true. // Indent can only be composed of space or tab characters. Indent string // AllowPartial allows messages that have missing required fields to marshal // without returning an error. If AllowPartial is false (the default), // Marshal will return error if there are any missing required fields. AllowPartial bool // UseProtoNames uses proto field name instead of lowerCamelCase name in JSON // field names. UseProtoNames bool // UseEnumNumbers emits enum values as numbers. UseEnumNumbers bool // EmitUnpopulated specifies whether to emit unpopulated fields. It does not // emit unpopulated oneof fields or unpopulated extension fields. // The JSON value emitted for unpopulated fields are as follows: // ╔═══════╤════════════════════════════╗ // ║ JSON │ Protobuf field ║ // ╠═══════╪════════════════════════════╣ // ║ false │ proto3 boolean fields ║ // ║ 0 │ proto3 numeric fields ║ // ║ "" │ proto3 string/bytes fields ║ // ║ null │ proto2 scalar fields ║ // ║ null │ message fields ║ // ║ [] │ list fields ║ // ║ {} │ map fields ║ // ╚═══════╧════════════════════════════╝ EmitUnpopulated bool // Resolver is used for looking up types when expanding google.protobuf.Any // messages. If nil, this defaults to using protoregistry.GlobalTypes. Resolver interface { protoregistry.ExtensionTypeResolver protoregistry.MessageTypeResolver } }
MarshalOptions is a configurable JSON format marshaler.
func (MarshalOptions) Format ¶
func (o MarshalOptions) Format(m proto.Message) string
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. It may change over time across different versions of the program.
type UnmarshalOptions ¶
type UnmarshalOptions struct { pragma.NoUnkeyedLiterals // If AllowPartial is set, input for messages that will result in missing // required fields will not return an error. AllowPartial bool // If DiscardUnknown is set, unknown fields are ignored. DiscardUnknown bool // Resolver is used for looking up types when unmarshaling // google.protobuf.Any messages or extension fields. // If nil, this defaults to using protoregistry.GlobalTypes. Resolver interface { protoregistry.MessageTypeResolver protoregistry.ExtensionTypeResolver } }
UnmarshalOptions is a configurable JSON format parser.
func (UnmarshalOptions) Unmarshal ¶
func (o UnmarshalOptions) Unmarshal(b []byte, m proto.Message) error
Unmarshal reads the given []byte and populates the given proto.Message using options in the UnmarshalOptions object. It will clear the message first before setting the fields. If it returns an error, the given message may be partially set. The provided message must be mutable (e.g., a non-nil pointer to a message).
Directories ¶
Path | Synopsis |
---|---|
internal
|
|
detrand
Package detrand provides deterministically random functionality.
|
Package detrand provides deterministically random functionality. |
encoding/messageset
Package messageset encodes and decodes the obsolete MessageSet wire format.
|
Package messageset encodes and decodes the obsolete MessageSet wire format. |
errors
Package errors implements functions to manipulate errors.
|
Package errors implements functions to manipulate errors. |
flags
Package flags provides a set of flags controlled by build tags.
|
Package flags provides a set of flags controlled by build tags. |
genid
Package genid contains constants for declarations in descriptor.proto and the well-known types.
|
Package genid contains constants for declarations in descriptor.proto and the well-known types. |
order
Package order provides ordered access to messages and maps.
|
Package order provides ordered access to messages and maps. |
pragma
Package pragma provides types that can be embedded into a struct to statically enforce or prevent certain language properties.
|
Package pragma provides types that can be embedded into a struct to statically enforce or prevent certain language properties. |
set
Package set provides simple set data structures for uint64s.
|
Package set provides simple set data structures for uint64s. |
strs
Package strs provides string manipulation functionality specific to protobuf.
|
Package strs provides string manipulation functionality specific to protobuf. |