package proto

Import Path
	github.com/golang/protobuf/proto (on go.dev)

Dependency Relation
	imports 23 packages, and imported by 3 packages

Involved Source Files buffer.go defaults.go deprecated.go discard.go extensions.go properties.go Package proto provides functionality for handling protocol buffer messages. In particular, it provides marshaling and unmarshaling between a protobuf message and the binary wire format. See https://developers.google.com/protocol-buffers/docs/gotutorial for more information. Deprecated: Use the "google.golang.org/protobuf/proto" package instead. registry.go text_decode.go text_encode.go wire.go wrappers.go
Package-Level Type Names (total 32, in which 19 are exported)
/* sort exporteds by: | */
Buffer is a buffer for encoding and decoding the protobuf wire format. It may be reused between invocations to reduce memory usage. Bytes returns the internal buffer. DebugPrint dumps the encoded bytes of b with a header and footer including s to stdout. This is only intended for debugging. DecodeFixed32 consumes a 32-bit little-endian integer from the buffer. DecodeFixed64 consumes a 64-bit little-endian integer from the buffer. DecodeGroup consumes a message group from the buffer. It assumes that the start group marker has already been consumed and consumes all bytes until (and including the end group marker). It does not reset m before unmarshaling. DecodeMessage consumes a length-prefixed message from the buffer. It does not reset m before unmarshaling. DecodeRawBytes consumes a length-prefixed raw bytes from the buffer. If alloc is specified, it returns a copy the raw bytes rather than a sub-slice of the buffer. DecodeStringBytes consumes a length-prefixed raw bytes from the buffer. It does not validate whether the raw bytes contain valid UTF-8. DecodeVarint consumes an encoded unsigned varint from the buffer. DecodeZigzag32 consumes an encoded 32-bit zig-zag varint from the buffer. DecodeZigzag64 consumes an encoded 64-bit zig-zag varint from the buffer. EncodeFixed32 appends a 32-bit little-endian integer to the buffer. EncodeFixed64 appends a 64-bit little-endian integer to the buffer. EncodeMessage appends a length-prefixed encoded message to the buffer. EncodeRawBytes appends a length-prefixed raw bytes to the buffer. EncodeStringBytes appends a length-prefixed raw bytes to the buffer. It does not validate whether v contains valid UTF-8. EncodeVarint appends an unsigned varint encoding to the buffer. EncodeZigzag32 appends a 32-bit zig-zag varint encoding to the buffer. EncodeZigzag64 appends a 64-bit zig-zag varint encoding to the buffer. Marshal appends the wire-format encoding of m to the buffer. Reset clears the internal buffer of all written and unread data. SetBuf sets buf as the internal buffer, where the contents of buf are considered the unread portion of the buffer. SetDeterministic specifies whether to use deterministic serialization. Deterministic serialization guarantees that for a given binary, equal messages will always be serialized to the same bytes. This implies: - Repeated serialization of a message will return the same bytes. - Different processes of the same binary (which may be executing on different machines) will serialize equal messages to the same bytes. Note that the deterministic serialization is NOT canonical across languages. It is not guaranteed to remain stable over time. It is unstable across different builds with schema changes due to unknown fields. Users who need canonical serialization (e.g., persistent storage in a canonical form, fingerprinting, etc.) should define their own canonicalization specification and implement their own serializer rather than relying on this API. If deterministic serialization is requested, map entries will be sorted by keys in lexographical order. This is an implementation detail and subject to change. Unmarshal parses the wire-format message in the buffer and places the decoded results in m. It does not reset m before unmarshaling. Unread returns the unread portion of the buffer. func NewBuffer(buf []byte) *Buffer
Deprecated: Do not use; this is an internal type.
ExtensionDesc represents an extension descriptor and is used to interact with an extension field in a message. Variables of this type are generated in code by protoc-gen-go.
ExtensionRange represents a range of message extensions. Used in code generated by protoc-gen-go.
GeneratedEnum is any enum type generated by protoc-gen-go which is a named int32 kind. This type exists for documentation purposes.
GeneratedMessage is any message type generated by protoc-gen-go which is a pointer to a named struct kind. This type exists for documentation purposes. func MessageV1(m GeneratedMessage) protoiface.MessageV1 func MessageV2(m GeneratedMessage) protoV2.Message
Deprecated: Do not use; this type existed for intenal-use only. Deprecated: Do not use; this method existed for intenal-use only. Deprecated: Do not use; this method existed for intenal-use only. Deprecated: Do not use; this method existed for intenal-use only. Deprecated: Do not use; this method existed for intenal-use only. Deprecated: Do not use; this method existed for intenal-use only.
Marshaler is implemented by messages that can marshal themselves. This interface is used by the following functions: Size, Marshal, Buffer.Marshal, and Buffer.EncodeMessage. Deprecated: Do not implement. ( T) Marshal() ([]byte, error) *github.com/pelletier/go-toml.Tree
Merger is implemented by messages that can merge themselves. This interface is used by the following functions: Clone and Merge. Deprecated: Do not implement. ( T) Merge(protoiface.MessageV1)
Message is a protocol buffer message. This is the v1 version of the message interface and is marginally better than an empty interface as it lacks any method to programatically interact with the contents of the message. A v2 message is declared in "google.golang.org/protobuf/proto".Message and exposes protobuf reflection as a first-class feature of the interface. To convert a v1 message to a v2 message, use the MessageV2 function. To convert a v2 message to a v1 message, use the MessageV1 function.
OneofProperties represents the type information for a protobuf oneof. Deprecated: Do not use. Field is the index into StructProperties.Prop for the containing oneof. Prop is the properties for the field. Type is a pointer to the generated wrapper type for the field value. This is nil for messages that are not in the open-struct API.
ParseError is returned by UnmarshalText. Deprecated: Do not use. Message string Deprecated: Do not use. (*T) Error() string *T : error
Properties represents the type information for a protobuf message field. Deprecated: Do not use. Default is the default value in string form. Enum is a placeholder name for enums. For historical reasons, this is neither the Go name for the enum, nor the protobuf name for the enum. // Deprecated: Do not use. HasDefault reports whether the field has a default value. JSONName is the JSON name for the protobuf field. MapKeyProp is the properties for the key field for a map field. MapValProp is the properties for the value field for a map field. Name is a placeholder name with little meaningful semantic value. If the name has an "XXX_" prefix, the entire Properties must be ignored. Oneof reports whether this field belongs within a oneof. Optional reports whether this is a optional field. OrigName is the protobuf field name or oneof name. Packed reports whether this is a packed repeated field of scalars. Proto3 reports whether this field operates under the proto3 syntax. Repeated reports whether this is a repeated field. Required reports whether this is a required field. Tag is the protobuf field number. Weak contains the full name of the weakly referenced message. Wire is a string representation of the wire type. WireType is the protobuf wire type for the field. Init populates the properties from a protocol buffer struct tag. Deprecated: Do not use. Parse populates p by parsing a string in the protobuf struct field tag style. String formats the properties in the protobuf struct field tag style. *T : fmt.Stringer
RequiredNotSetError is an error type returned when marshaling or unmarshaling a message with missing required fields. (*T) Error() string (*T) RequiredNotSet() bool *T : error
Deprecated: Do not use. Chit uint64 Cmiss uint64 Decode uint64 Dmalloc uint64 Emalloc uint64 Encode uint64 Size uint64 func GetStats() Stats
StructProperties represents protocol buffer type information for a generated protobuf message in the open-struct API. Deprecated: Do not use. OneofTypes contains information about the oneof fields in this message. It is keyed by the protobuf field name. Prop are the properties for each field. Fields belonging to a oneof are stored in OneofTypes instead, with a single Properties representing the parent oneof held here. The order of Prop matches the order of fields in the Go struct. Struct fields that are not related to protobufs have a "XXX_" prefix in the Properties.Name and must be ignored by the user. (*T) Len() int (*T) Less(i, j int) bool (*T) Swap(i, j int) *T : sort.Interface func GetProperties(t reflect.Type) *StructProperties
TextMarshaler is a configurable text format marshaler. // use compact text format (one line) // expand google.protobuf.Any messages of known types Marshal writes the proto text format of m to w. Text returns a proto text formatted string of m.
Unmarshaler is implemented by messages that can unmarshal themselves. This interface is used by the following functions: Unmarshal, UnmarshalMerge, Buffer.Unmarshal, Buffer.DecodeMessage, and Buffer.DecodeGroup. Deprecated: Do not implement. ( T) Unmarshal([]byte) error
Deprecated: Do not use; this is an internal type.
Package-Level Functions (total 78, in which 57 are exported)
Bool stores v in a new bool value and returns a pointer to it.
ClearAllExtensions clears all extensions from m. This includes populated fields and unknown fields in the extension range.
ClearExtension removes the extension field from m either as an explicitly populated field or as an unknown field.
Clone returns a deep copy of src.
CompactText writes the compact proto text format of m to w.
CompactTextString returns a compact proto text formatted string of m.
DecodeVarint parses a varint encoded integer from b, returning the integer value and the length of the varint. It returns (0, 0) if there is a parse error.
DiscardUnknown recursively discards all unknown fields from this message and all embedded messages. When unmarshaling a message with unrecognized fields, the tags and values of such fields are preserved in the Message. This allows a later call to marshal to be able to produce a message that continues to have those unrecognized fields. To avoid this, DiscardUnknown is used to explicitly clear the unknown fields after unmarshaling.
EncodeVarint returns the varint encoded bytes of v.
Deprecated: Do not use.
EnumValueMap returns the mapping from enum value names to enum numbers for the enum of the given name. It returns nil if not found. Deprecated: Use protoregistry.GlobalTypes.FindEnumByName instead.
Equal reports whether two messages are equal. If two messages marshal to the same bytes under deterministic serialization, then Equal is guaranteed to report true. Two messages are equal if they are the same protobuf message type, have the same set of populated known and extension field values, and the same set of unknown fields values. Scalar values are compared with the equivalent of the == operator in Go, except bytes values which are compared using bytes.Equal and floating point values which specially treat NaNs as equal. Message values are compared by recursively calling Equal. Lists are equal if each element value is also equal. Maps are equal if they have the same set of keys, where the pair of values for each key is also equal.
ExtensionDescs returns a list of extension descriptors found in m, containing descriptors for both populated extension fields in m and also unknown fields of m that are in the extension range. For the later case, an type incomplete descriptor is provided where only the ExtensionDesc.Field field is populated. The order of the extension descriptors is undefined.
FileDescriptor returns the compressed FileDescriptorProto given the file path for a proto source file. It returns nil if not found. Deprecated: Use protoregistry.GlobalFiles.FindFileByPath instead.
Float32 stores v in a new float32 value and returns a pointer to it.
Float64 stores v in a new float64 value and returns a pointer to it.
GetExtension retrieves a proto2 extended field from m. If the descriptor is type complete (i.e., ExtensionDesc.ExtensionType is non-nil), then GetExtension parses the encoded field and returns a Go value of the specified type. If the field is not present, then the default value is returned (if one is specified), otherwise ErrMissingExtension is reported. If the descriptor is type incomplete (i.e., ExtensionDesc.ExtensionType is nil), then GetExtension returns the raw encoded bytes for the extension field.
GetExtensions returns a list of the extensions values present in m, corresponding with the provided list of extension descriptors, xts. If an extension is missing in m, the corresponding value is nil.
GetProperties returns the list of properties for the type represented by t, which must be a generated protocol buffer message in the open-struct API, where protobuf message fields are represented by exported Go struct fields. Deprecated: Use protobuf reflection instead.
Deprecated: Do not use.
HasExtension reports whether the extension field is present in m either as an explicitly populated field or as an unknown field.
Int stores v in a new int32 value and returns a pointer to it. Deprecated: Use Int32 instead.
Int32 stores v in a new int32 value and returns a pointer to it.
Int64 stores v in a new int64 value and returns a pointer to it.
Marshal returns the wire-format encoding of m.
Deprecated: Do not use.
Deprecated: Do not use.
MarshalText writes the proto text format of m to w.
MarshalTextString returns a proto text formatted string of m.
Merge merges src into dst, which must be messages of the same type. Populated scalar fields in src are copied to dst, while populated singular messages in src are merged into dst by recursively calling Merge. The elements of every list field in src is appended to the corresponded list fields in dst. The entries of every map field in src is copied into the corresponding map field in dst, possibly replacing existing entries. The unknown fields of src are appended to the unknown fields of dst.
MessageName returns the full protobuf name for the given message type. Deprecated: Use protoreflect.MessageDescriptor.FullName instead.
MessageReflect returns a reflective view for a message. It returns nil if m is nil.
MessageType returns the message type for a named message. It returns nil if not found. Deprecated: Use protoregistry.GlobalTypes.FindMessageByName instead.
MessageV1 converts either a v1 or v2 message to a v1 message. It returns nil if m is nil.
MessageV2 converts either a v1 or v2 message to a v2 message. It returns nil if m is nil.
NewBuffer allocates a new Buffer initialized with buf, where the contents of buf are considered the unread portion of the buffer.
RegisteredExtensions returns a map of the registered extensions for the provided protobuf message, indexed by the extension field number. Deprecated: Use protoregistry.GlobalTypes.RangeExtensionsByMessage instead.
RegisterEnum is called from the generated code to register the mapping of enum value names to enum numbers for the enum identified by s. Deprecated: Use protoregistry.GlobalTypes.RegisterEnum instead.
RegisterExtension is called from the generated code to register the extension descriptor. Deprecated: Use protoregistry.GlobalTypes.RegisterExtension instead.
RegisterFile is called from generated code to register the compressed FileDescriptorProto with the file path for a proto source file. Deprecated: Use protoregistry.GlobalFiles.RegisterFile instead.
RegisterMapType is called from generated code to register the Go map type for a protobuf message representing a map entry. Deprecated: Do not use.
Deprecated: Do not use.
RegisterType is called from generated code to register the message Go type for a message of the given name. Deprecated: Use protoregistry.GlobalTypes.RegisterMessage instead.
SetDefaults sets unpopulated scalar fields to their default values. Fields within a oneof are not set even if they have a default value. SetDefaults is recursively called upon any populated message fields.
SetExtension sets an extension field in m to the provided value.
SetRawExtension inserts b into the unknown fields of m. Deprecated: Use Message.ProtoReflect.SetUnknown instead.
Size returns the size in bytes of the wire-format encoding of m.
SizeVarint returns the length of the varint encoded bytes of v. This is equal to len(EncodeVarint(v)).
String stores v in a new string value and returns a pointer to it.
Uint32 stores v in a new uint32 value and returns a pointer to it.
Uint64 stores v in a new uint64 value and returns a pointer to it.
Unmarshal parses a wire-format message in b and places the decoded results in m. Unmarshal resets m before starting to unmarshal, so any existing data in m is always removed. Use UnmarshalMerge to preserve and append to existing data.
Deprecated: Do not use.
UnmarshalMerge parses a wire-format message in b and places the decoded results in m.
Deprecated: Do not use.
Deprecated: Do not use.
UnmarshalText parses a proto text formatted string into m.
Package-Level Variables (total 20, in which 4 are exported)
Deprecated: No longer returned.
ErrMissingExtension reports whether the extension was not present.
Deprecated: No longer returned.
Deprecated: No longer returned.
Package-Level Constants (total 12, in which 10 are exported)
const WireBytes = 2
const WireEndGroup = 4
const WireFixed32 = 5
const WireFixed64 = 1
const WireStartGroup = 3
const WireVarint = 0