Documentation ¶
Index ¶
- func IsMessageSet(md pref.MessageDescriptor) bool
- func IsMessageSetExtension(fd pref.FieldDescriptor) bool
- func JSONCamelCase(s string) string
- func JSONSnakeCase(s string) string
- func Marshal(m proto.Message) (bson.D, error)
- func Unmarshal(doc interface{}, m proto.Message) error
- type Ints
- type MarshalOptions
- type NoUnkeyedLiterals
- type UnmarshalOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsMessageSet ¶
func IsMessageSet(md pref.MessageDescriptor) bool
IsMessageSet returns whether the message uses the MessageSet wire format.
func IsMessageSetExtension ¶
func IsMessageSetExtension(fd pref.FieldDescriptor) bool
IsMessageSetExtension reports this field extends a MessageSet.
func JSONCamelCase ¶
JSONCamelCase converts a snake_case identifier to a camelCase identifier, according to the protobuf JSON specification.
func JSONSnakeCase ¶
JSONSnakeCase converts a camelCase identifier to a snake_case identifier, according to the protobuf JSON specification.
Types ¶
type Ints ¶
type Ints struct {
// contains filtered or unexported fields
}
Ints represents a set of integers within the range of 0..math.MaxUint64.
type MarshalOptions ¶
type MarshalOptions struct { 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) Marshal ¶
func (o MarshalOptions) Marshal(m proto.Message) (interface{}, error)
Marshal marshals the given proto.Message in the JSON format using options in MarshalOptions. Do not depend on the output being stable. It may change over time across different versions of the program.
type NoUnkeyedLiterals ¶
type NoUnkeyedLiterals struct{}
NoUnkeyedLiterals can be embedded in a struct to prevent unkeyed literals.
type UnmarshalOptions ¶
type UnmarshalOptions struct { 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(doc interface{}, m proto.Message) error
Unmarshal reads the given []byte and populates the given proto.Message using options in UnmarshalOptions object. It will clear the message first before setting the fields. If it returns an error, the given message may be partially set.
func (UnmarshalOptions) UnmarshalBytes ¶
func (o UnmarshalOptions) UnmarshalBytes(b []byte, m proto.Message) error
UnmarshalBytes ...