Documentation

Overview

    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.

    Index

    Constants

    View Source
    const (
    	WireVarint     = 0
    	WireFixed32    = 5
    	WireFixed64    = 1
    	WireBytes      = 2
    	WireStartGroup = 3
    	WireEndGroup   = 4
    )
    View Source
    const (
    	ProtoPackageIsVersion1 = true
    	ProtoPackageIsVersion2 = true
    	ProtoPackageIsVersion3 = true
    	ProtoPackageIsVersion4 = true
    )

    Variables

    View Source
    var (
    	// Deprecated: No longer returned.
    	ErrNil = errors.New("proto: Marshal called with nil")
    
    	// Deprecated: No longer returned.
    	ErrTooLarge = errors.New("proto: message encodes to over 2 GB")
    
    	// Deprecated: No longer returned.
    	ErrInternalBadWireType = errors.New("proto: internal error: bad wiretype for oneof")
    )
    View Source
    var ErrMissingExtension = errors.New("proto: missing extension")

      ErrMissingExtension reports whether the extension was not present.

      Functions

      func Bool

      func Bool(v bool) *bool

        Bool stores v in a new bool value and returns a pointer to it.

        func ClearAllExtensions

        func ClearAllExtensions(m Message)

          ClearAllExtensions clears all extensions from m. This includes populated fields and unknown fields in the extension range.

          func ClearExtension

          func ClearExtension(m Message, xt *ExtensionDesc)

            ClearExtension removes the extension field from m either as an explicitly populated field or as an unknown field.

            func CompactText

            func CompactText(w io.Writer, m Message) error

              CompactText writes the compact proto text format of m to w.

              func CompactTextString

              func CompactTextString(m Message) string

                CompactTextString returns a compact proto text formatted string of m.

                func DecodeVarint

                func DecodeVarint(b []byte) (uint64, int)

                  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.

                  func DiscardUnknown

                  func DiscardUnknown(m Message)

                    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.

                    func EncodeVarint

                    func EncodeVarint(v uint64) []byte

                      EncodeVarint returns the varint encoded bytes of v.

                      func EnumName

                      func EnumName(m map[int32]string, v int32) string

                        Deprecated: Do not use.

                        func EnumValueMap

                        func EnumValueMap(s enumName) enumsByName

                          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.

                          func Equal

                          func Equal(x, y Message) bool

                            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.

                            func FileDescriptor

                            func FileDescriptor(s filePath) fileDescGZIP

                              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.

                              func Float32

                              func Float32(v float32) *float32

                                Float32 stores v in a new float32 value and returns a pointer to it.

                                func Float64

                                func Float64(v float64) *float64

                                  Float64 stores v in a new float64 value and returns a pointer to it.

                                  func GetExtension

                                  func GetExtension(m Message, xt *ExtensionDesc) (interface{}, error)

                                    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.

                                    func GetExtensions

                                    func GetExtensions(m Message, xts []*ExtensionDesc) ([]interface{}, error)

                                      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.

                                      func HasExtension

                                      func HasExtension(m Message, xt *ExtensionDesc) (has bool)

                                        HasExtension reports whether the extension field is present in m either as an explicitly populated field or as an unknown field.

                                        func Int

                                        func Int(v int) *int32

                                          Int stores v in a new int32 value and returns a pointer to it.

                                          Deprecated: Use Int32 instead.

                                          func Int32

                                          func Int32(v int32) *int32

                                            Int32 stores v in a new int32 value and returns a pointer to it.

                                            func Int64

                                            func Int64(v int64) *int64

                                              Int64 stores v in a new int64 value and returns a pointer to it.

                                              func Marshal

                                              func Marshal(m Message) ([]byte, error)

                                                Marshal returns the wire-format encoding of m.

                                                func MarshalMessageSet

                                                func MarshalMessageSet(interface{}) ([]byte, error)

                                                  Deprecated: Do not use.

                                                  func MarshalMessageSetJSON

                                                  func MarshalMessageSetJSON(interface{}) ([]byte, error)

                                                    Deprecated: Do not use.

                                                    func MarshalText

                                                    func MarshalText(w io.Writer, m Message) error

                                                      MarshalText writes the proto text format of m to w.

                                                      func MarshalTextString

                                                      func MarshalTextString(m Message) string

                                                        MarshalTextString returns a proto text formatted string of m.

                                                        func Merge

                                                        func Merge(dst, src Message)

                                                          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.

                                                          func MessageName

                                                          func MessageName(m Message) messageName

                                                            MessageName returns the full protobuf name for the given message type.

                                                            Deprecated: Use protoreflect.MessageDescriptor.FullName instead.

                                                            func MessageReflect

                                                            func MessageReflect(m Message) protoreflect.Message

                                                              MessageReflect returns a reflective view for a message. It returns nil if m is nil.

                                                              func MessageType

                                                              func MessageType(s messageName) reflect.Type

                                                                MessageType returns the message type for a named message. It returns nil if not found.

                                                                Deprecated: Use protoregistry.GlobalTypes.FindMessageByName instead.

                                                                func MessageV1

                                                                  MessageV1 converts either a v1 or v2 message to a v1 message. It returns nil if m is nil.

                                                                  func MessageV2

                                                                  func MessageV2(m GeneratedMessage) protoV2.Message

                                                                    MessageV2 converts either a v1 or v2 message to a v2 message. It returns nil if m is nil.

                                                                    func RegisterEnum

                                                                    func RegisterEnum(s enumName, _ enumsByNumber, m enumsByName)

                                                                      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.

                                                                      func RegisterExtension

                                                                      func RegisterExtension(d *ExtensionDesc)

                                                                        RegisterExtension is called from the generated code to register the extension descriptor.

                                                                        Deprecated: Use protoregistry.GlobalTypes.RegisterExtension instead.

                                                                        func RegisterFile

                                                                        func RegisterFile(s filePath, d fileDescGZIP)

                                                                          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.

                                                                          func RegisterMapType

                                                                          func RegisterMapType(m interface{}, s messageName)

                                                                            RegisterMapType is called from generated code to register the Go map type for a protobuf message representing a map entry.

                                                                            Deprecated: Do not use.

                                                                            func RegisterMessageSetType

                                                                            func RegisterMessageSetType(Message, int32, string)

                                                                              Deprecated: Do not use.

                                                                              func RegisterType

                                                                              func RegisterType(m Message, s messageName)

                                                                                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.

                                                                                func RegisteredExtensions

                                                                                func RegisteredExtensions(m Message) extensionsByNumber

                                                                                  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.

                                                                                  func SetDefaults

                                                                                  func SetDefaults(m Message)

                                                                                    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.

                                                                                    func SetExtension

                                                                                    func SetExtension(m Message, xt *ExtensionDesc, v interface{}) error

                                                                                      SetExtension sets an extension field in m to the provided value.

                                                                                      func SetRawExtension

                                                                                      func SetRawExtension(m Message, fnum int32, b []byte)

                                                                                        SetRawExtension inserts b into the unknown fields of m.

                                                                                        Deprecated: Use Message.ProtoReflect.SetUnknown instead.

                                                                                        func Size

                                                                                        func Size(m Message) int

                                                                                          Size returns the size in bytes of the wire-format encoding of m.

                                                                                          func SizeVarint

                                                                                          func SizeVarint(v uint64) int

                                                                                            SizeVarint returns the length of the varint encoded bytes of v. This is equal to len(EncodeVarint(v)).

                                                                                            func String

                                                                                            func String(v string) *string

                                                                                              String stores v in a new string value and returns a pointer to it.

                                                                                              func Uint32

                                                                                              func Uint32(v uint32) *uint32

                                                                                                Uint32 stores v in a new uint32 value and returns a pointer to it.

                                                                                                func Uint64

                                                                                                func Uint64(v uint64) *uint64

                                                                                                  Uint64 stores v in a new uint64 value and returns a pointer to it.

                                                                                                  func Unmarshal

                                                                                                  func Unmarshal(b []byte, m Message) error

                                                                                                    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.

                                                                                                    func UnmarshalJSONEnum

                                                                                                    func UnmarshalJSONEnum(m map[string]int32, data []byte, enumName string) (int32, error)

                                                                                                      Deprecated: Do not use.

                                                                                                      func UnmarshalMerge

                                                                                                      func UnmarshalMerge(b []byte, m Message) error

                                                                                                        UnmarshalMerge parses a wire-format message in b and places the decoded results in m.

                                                                                                        func UnmarshalMessageSet

                                                                                                        func UnmarshalMessageSet([]byte, interface{}) error

                                                                                                          Deprecated: Do not use.

                                                                                                          func UnmarshalMessageSetJSON

                                                                                                          func UnmarshalMessageSetJSON([]byte, interface{}) error

                                                                                                            Deprecated: Do not use.

                                                                                                            func UnmarshalText

                                                                                                            func UnmarshalText(s string, m Message) error

                                                                                                              UnmarshalText parses a proto text formatted string into m.

                                                                                                              Types

                                                                                                              type Buffer

                                                                                                              type Buffer struct {
                                                                                                              	// contains filtered or unexported fields
                                                                                                              }

                                                                                                                Buffer is a buffer for encoding and decoding the protobuf wire format. It may be reused between invocations to reduce memory usage.

                                                                                                                func NewBuffer

                                                                                                                func NewBuffer(buf []byte) *Buffer

                                                                                                                  NewBuffer allocates a new Buffer initialized with buf, where the contents of buf are considered the unread portion of the buffer.

                                                                                                                  func (*Buffer) Bytes

                                                                                                                  func (b *Buffer) Bytes() []byte

                                                                                                                    Bytes returns the internal buffer.

                                                                                                                    func (*Buffer) DebugPrint

                                                                                                                    func (*Buffer) DebugPrint(s string, b []byte)

                                                                                                                      DebugPrint dumps the encoded bytes of b with a header and footer including s to stdout. This is only intended for debugging.

                                                                                                                      func (*Buffer) DecodeFixed32

                                                                                                                      func (b *Buffer) DecodeFixed32() (uint64, error)

                                                                                                                        DecodeFixed32 consumes a 32-bit little-endian integer from the buffer.

                                                                                                                        func (*Buffer) DecodeFixed64

                                                                                                                        func (b *Buffer) DecodeFixed64() (uint64, error)

                                                                                                                          DecodeFixed64 consumes a 64-bit little-endian integer from the buffer.

                                                                                                                          func (*Buffer) DecodeGroup

                                                                                                                          func (b *Buffer) DecodeGroup(m Message) error

                                                                                                                            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.

                                                                                                                            func (*Buffer) DecodeMessage

                                                                                                                            func (b *Buffer) DecodeMessage(m Message) error

                                                                                                                              DecodeMessage consumes a length-prefixed message from the buffer. It does not reset m before unmarshaling.

                                                                                                                              func (*Buffer) DecodeRawBytes

                                                                                                                              func (b *Buffer) DecodeRawBytes(alloc bool) ([]byte, error)

                                                                                                                                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.

                                                                                                                                func (*Buffer) DecodeStringBytes

                                                                                                                                func (b *Buffer) DecodeStringBytes() (string, error)

                                                                                                                                  DecodeStringBytes consumes a length-prefixed raw bytes from the buffer. It does not validate whether the raw bytes contain valid UTF-8.

                                                                                                                                  func (*Buffer) DecodeVarint

                                                                                                                                  func (b *Buffer) DecodeVarint() (uint64, error)

                                                                                                                                    DecodeVarint consumes an encoded unsigned varint from the buffer.

                                                                                                                                    func (*Buffer) DecodeZigzag32

                                                                                                                                    func (b *Buffer) DecodeZigzag32() (uint64, error)

                                                                                                                                      DecodeZigzag32 consumes an encoded 32-bit zig-zag varint from the buffer.

                                                                                                                                      func (*Buffer) DecodeZigzag64

                                                                                                                                      func (b *Buffer) DecodeZigzag64() (uint64, error)

                                                                                                                                        DecodeZigzag64 consumes an encoded 64-bit zig-zag varint from the buffer.

                                                                                                                                        func (*Buffer) EncodeFixed32

                                                                                                                                        func (b *Buffer) EncodeFixed32(v uint64) error

                                                                                                                                          EncodeFixed32 appends a 32-bit little-endian integer to the buffer.

                                                                                                                                          func (*Buffer) EncodeFixed64

                                                                                                                                          func (b *Buffer) EncodeFixed64(v uint64) error

                                                                                                                                            EncodeFixed64 appends a 64-bit little-endian integer to the buffer.

                                                                                                                                            func (*Buffer) EncodeMessage

                                                                                                                                            func (b *Buffer) EncodeMessage(m Message) error

                                                                                                                                              EncodeMessage appends a length-prefixed encoded message to the buffer.

                                                                                                                                              func (*Buffer) EncodeRawBytes

                                                                                                                                              func (b *Buffer) EncodeRawBytes(v []byte) error

                                                                                                                                                EncodeRawBytes appends a length-prefixed raw bytes to the buffer.

                                                                                                                                                func (*Buffer) EncodeStringBytes

                                                                                                                                                func (b *Buffer) EncodeStringBytes(v string) error

                                                                                                                                                  EncodeStringBytes appends a length-prefixed raw bytes to the buffer. It does not validate whether v contains valid UTF-8.

                                                                                                                                                  func (*Buffer) EncodeVarint

                                                                                                                                                  func (b *Buffer) EncodeVarint(v uint64) error

                                                                                                                                                    EncodeVarint appends an unsigned varint encoding to the buffer.

                                                                                                                                                    func (*Buffer) EncodeZigzag32

                                                                                                                                                    func (b *Buffer) EncodeZigzag32(v uint64) error

                                                                                                                                                      EncodeZigzag32 appends a 32-bit zig-zag varint encoding to the buffer.

                                                                                                                                                      func (*Buffer) EncodeZigzag64

                                                                                                                                                      func (b *Buffer) EncodeZigzag64(v uint64) error

                                                                                                                                                        EncodeZigzag64 appends a 64-bit zig-zag varint encoding to the buffer.

                                                                                                                                                        func (*Buffer) Marshal

                                                                                                                                                        func (b *Buffer) Marshal(m Message) error

                                                                                                                                                          Marshal appends the wire-format encoding of m to the buffer.

                                                                                                                                                          func (*Buffer) Reset

                                                                                                                                                          func (b *Buffer) Reset()

                                                                                                                                                            Reset clears the internal buffer of all written and unread data.

                                                                                                                                                            func (*Buffer) SetBuf

                                                                                                                                                            func (b *Buffer) SetBuf(buf []byte)

                                                                                                                                                              SetBuf sets buf as the internal buffer, where the contents of buf are considered the unread portion of the buffer.

                                                                                                                                                              func (*Buffer) SetDeterministic

                                                                                                                                                              func (b *Buffer) SetDeterministic(deterministic bool)

                                                                                                                                                                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.

                                                                                                                                                                func (*Buffer) Unmarshal

                                                                                                                                                                func (b *Buffer) Unmarshal(m Message) error

                                                                                                                                                                  Unmarshal parses the wire-format message in the buffer and places the decoded results in m. It does not reset m before unmarshaling.

                                                                                                                                                                  func (*Buffer) Unread

                                                                                                                                                                  func (b *Buffer) Unread() []byte

                                                                                                                                                                    Unread returns the unread portion of the buffer.

                                                                                                                                                                    type Extension

                                                                                                                                                                    type Extension = protoimpl.ExtensionFieldV1

                                                                                                                                                                      Deprecated: Do not use; this is an internal type.

                                                                                                                                                                      type ExtensionDesc

                                                                                                                                                                      type ExtensionDesc = protoimpl.ExtensionInfo

                                                                                                                                                                        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.

                                                                                                                                                                        func ExtensionDescs

                                                                                                                                                                        func ExtensionDescs(m Message) ([]*ExtensionDesc, error)

                                                                                                                                                                          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.

                                                                                                                                                                          type ExtensionRange

                                                                                                                                                                          type ExtensionRange = protoiface.ExtensionRangeV1

                                                                                                                                                                            ExtensionRange represents a range of message extensions. Used in code generated by protoc-gen-go.

                                                                                                                                                                            type GeneratedEnum

                                                                                                                                                                            type GeneratedEnum interface{}

                                                                                                                                                                              GeneratedEnum is any enum type generated by protoc-gen-go which is a named int32 kind. This type exists for documentation purposes.

                                                                                                                                                                              type GeneratedMessage

                                                                                                                                                                              type GeneratedMessage interface{}

                                                                                                                                                                                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.

                                                                                                                                                                                type InternalMessageInfo

                                                                                                                                                                                type InternalMessageInfo struct{}

                                                                                                                                                                                  Deprecated: Do not use; this type existed for intenal-use only.

                                                                                                                                                                                  func (*InternalMessageInfo) DiscardUnknown

                                                                                                                                                                                  func (*InternalMessageInfo) DiscardUnknown(m Message)

                                                                                                                                                                                    Deprecated: Do not use; this method existed for intenal-use only.

                                                                                                                                                                                    func (*InternalMessageInfo) Marshal

                                                                                                                                                                                    func (*InternalMessageInfo) Marshal(b []byte, m Message, deterministic bool) ([]byte, error)

                                                                                                                                                                                      Deprecated: Do not use; this method existed for intenal-use only.

                                                                                                                                                                                      func (*InternalMessageInfo) Merge

                                                                                                                                                                                      func (*InternalMessageInfo) Merge(dst, src Message)

                                                                                                                                                                                        Deprecated: Do not use; this method existed for intenal-use only.

                                                                                                                                                                                        func (*InternalMessageInfo) Size

                                                                                                                                                                                        func (*InternalMessageInfo) Size(m Message) int

                                                                                                                                                                                          Deprecated: Do not use; this method existed for intenal-use only.

                                                                                                                                                                                          func (*InternalMessageInfo) Unmarshal

                                                                                                                                                                                          func (*InternalMessageInfo) Unmarshal(m Message, b []byte) error

                                                                                                                                                                                            Deprecated: Do not use; this method existed for intenal-use only.

                                                                                                                                                                                            type Marshaler

                                                                                                                                                                                            type Marshaler interface {
                                                                                                                                                                                            	// Marshal formats the encoded bytes of the message.
                                                                                                                                                                                            	// It should be deterministic and emit valid protobuf wire data.
                                                                                                                                                                                            	// The caller takes ownership of the returned buffer.
                                                                                                                                                                                            	Marshal() ([]byte, error)
                                                                                                                                                                                            }

                                                                                                                                                                                              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.

                                                                                                                                                                                              type Merger

                                                                                                                                                                                              type Merger interface {
                                                                                                                                                                                              	// Merge merges the contents of src into the receiver message.
                                                                                                                                                                                              	// It clones all data structures in src such that it aliases no mutable
                                                                                                                                                                                              	// memory referenced by src.
                                                                                                                                                                                              	Merge(src Message)
                                                                                                                                                                                              }

                                                                                                                                                                                                Merger is implemented by messages that can merge themselves. This interface is used by the following functions: Clone and Merge.

                                                                                                                                                                                                Deprecated: Do not implement.

                                                                                                                                                                                                type Message

                                                                                                                                                                                                type Message = 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.

                                                                                                                                                                                                  func Clone

                                                                                                                                                                                                  func Clone(src Message) Message

                                                                                                                                                                                                    Clone returns a deep copy of src.

                                                                                                                                                                                                    type OneofProperties

                                                                                                                                                                                                    type OneofProperties struct {
                                                                                                                                                                                                    	// 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.
                                                                                                                                                                                                    	Type reflect.Type
                                                                                                                                                                                                    	// Field is the index into StructProperties.Prop for the containing oneof.
                                                                                                                                                                                                    	Field int
                                                                                                                                                                                                    	// Prop is the properties for the field.
                                                                                                                                                                                                    	Prop *Properties
                                                                                                                                                                                                    }

                                                                                                                                                                                                      OneofProperties represents the type information for a protobuf oneof.

                                                                                                                                                                                                      Deprecated: Do not use.

                                                                                                                                                                                                      type ParseError

                                                                                                                                                                                                      type ParseError struct {
                                                                                                                                                                                                      	Message string
                                                                                                                                                                                                      
                                                                                                                                                                                                      	// Deprecated: Do not use.
                                                                                                                                                                                                      	Line, Offset int
                                                                                                                                                                                                      }

                                                                                                                                                                                                        ParseError is returned by UnmarshalText.

                                                                                                                                                                                                        func (*ParseError) Error

                                                                                                                                                                                                        func (e *ParseError) Error() string

                                                                                                                                                                                                        type Properties

                                                                                                                                                                                                        type Properties struct {
                                                                                                                                                                                                        	// Name is a placeholder name with little meaningful semantic value.
                                                                                                                                                                                                        	// If the name has an "XXX_" prefix, the entire Properties must be ignored.
                                                                                                                                                                                                        	Name string
                                                                                                                                                                                                        	// OrigName is the protobuf field name or oneof name.
                                                                                                                                                                                                        	OrigName string
                                                                                                                                                                                                        	// JSONName is the JSON name for the protobuf field.
                                                                                                                                                                                                        	JSONName string
                                                                                                                                                                                                        	// 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.
                                                                                                                                                                                                        	Enum string // Deprecated: Do not use.
                                                                                                                                                                                                        	// Weak contains the full name of the weakly referenced message.
                                                                                                                                                                                                        	Weak string
                                                                                                                                                                                                        	// Wire is a string representation of the wire type.
                                                                                                                                                                                                        	Wire string
                                                                                                                                                                                                        	// WireType is the protobuf wire type for the field.
                                                                                                                                                                                                        	WireType int
                                                                                                                                                                                                        	// Tag is the protobuf field number.
                                                                                                                                                                                                        	Tag int
                                                                                                                                                                                                        	// Required reports whether this is a required field.
                                                                                                                                                                                                        	Required bool
                                                                                                                                                                                                        	// Optional reports whether this is a optional field.
                                                                                                                                                                                                        	Optional bool
                                                                                                                                                                                                        	// Repeated reports whether this is a repeated field.
                                                                                                                                                                                                        	Repeated bool
                                                                                                                                                                                                        	// Packed reports whether this is a packed repeated field of scalars.
                                                                                                                                                                                                        	Packed bool
                                                                                                                                                                                                        	// Proto3 reports whether this field operates under the proto3 syntax.
                                                                                                                                                                                                        	Proto3 bool
                                                                                                                                                                                                        	// Oneof reports whether this field belongs within a oneof.
                                                                                                                                                                                                        	Oneof bool
                                                                                                                                                                                                        
                                                                                                                                                                                                        	// Default is the default value in string form.
                                                                                                                                                                                                        	Default string
                                                                                                                                                                                                        	// HasDefault reports whether the field has a default value.
                                                                                                                                                                                                        	HasDefault bool
                                                                                                                                                                                                        
                                                                                                                                                                                                        	// MapKeyProp is the properties for the key field for a map field.
                                                                                                                                                                                                        	MapKeyProp *Properties
                                                                                                                                                                                                        	// MapValProp is the properties for the value field for a map field.
                                                                                                                                                                                                        	MapValProp *Properties
                                                                                                                                                                                                        }

                                                                                                                                                                                                          Properties represents the type information for a protobuf message field.

                                                                                                                                                                                                          Deprecated: Do not use.

                                                                                                                                                                                                          func (*Properties) Init

                                                                                                                                                                                                          func (p *Properties) Init(typ reflect.Type, name, tag string, f *reflect.StructField)

                                                                                                                                                                                                            Init populates the properties from a protocol buffer struct tag.

                                                                                                                                                                                                            Deprecated: Do not use.

                                                                                                                                                                                                            func (*Properties) Parse

                                                                                                                                                                                                            func (p *Properties) Parse(tag string)

                                                                                                                                                                                                              Parse populates p by parsing a string in the protobuf struct field tag style.

                                                                                                                                                                                                              func (*Properties) String

                                                                                                                                                                                                              func (p *Properties) String() string

                                                                                                                                                                                                                String formats the properties in the protobuf struct field tag style.

                                                                                                                                                                                                                type RequiredNotSetError

                                                                                                                                                                                                                type RequiredNotSetError struct {
                                                                                                                                                                                                                	// contains filtered or unexported fields
                                                                                                                                                                                                                }

                                                                                                                                                                                                                  RequiredNotSetError is an error type returned when marshaling or unmarshaling a message with missing required fields.

                                                                                                                                                                                                                  func (*RequiredNotSetError) Error

                                                                                                                                                                                                                  func (e *RequiredNotSetError) Error() string

                                                                                                                                                                                                                  func (*RequiredNotSetError) RequiredNotSet

                                                                                                                                                                                                                  func (e *RequiredNotSetError) RequiredNotSet() bool

                                                                                                                                                                                                                  type Stats

                                                                                                                                                                                                                  type Stats struct{ Emalloc, Dmalloc, Encode, Decode, Chit, Cmiss, Size uint64 }

                                                                                                                                                                                                                    Deprecated: Do not use.

                                                                                                                                                                                                                    func GetStats

                                                                                                                                                                                                                    func GetStats() Stats

                                                                                                                                                                                                                      Deprecated: Do not use.

                                                                                                                                                                                                                      type StructProperties

                                                                                                                                                                                                                      type StructProperties struct {
                                                                                                                                                                                                                      	// 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.
                                                                                                                                                                                                                      	Prop []*Properties
                                                                                                                                                                                                                      
                                                                                                                                                                                                                      	// OneofTypes contains information about the oneof fields in this message.
                                                                                                                                                                                                                      	// It is keyed by the protobuf field name.
                                                                                                                                                                                                                      	OneofTypes map[string]*OneofProperties
                                                                                                                                                                                                                      }

                                                                                                                                                                                                                        StructProperties represents protocol buffer type information for a generated protobuf message in the open-struct API.

                                                                                                                                                                                                                        Deprecated: Do not use.

                                                                                                                                                                                                                        func GetProperties

                                                                                                                                                                                                                        func GetProperties(t reflect.Type) *StructProperties

                                                                                                                                                                                                                          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.

                                                                                                                                                                                                                          func (*StructProperties) Len

                                                                                                                                                                                                                          func (sp *StructProperties) Len() int

                                                                                                                                                                                                                          func (*StructProperties) Less

                                                                                                                                                                                                                          func (sp *StructProperties) Less(i, j int) bool

                                                                                                                                                                                                                          func (*StructProperties) Swap

                                                                                                                                                                                                                          func (sp *StructProperties) Swap(i, j int)

                                                                                                                                                                                                                          type TextMarshaler

                                                                                                                                                                                                                          type TextMarshaler struct {
                                                                                                                                                                                                                          	Compact   bool // use compact text format (one line)
                                                                                                                                                                                                                          	ExpandAny bool // expand google.protobuf.Any messages of known types
                                                                                                                                                                                                                          }

                                                                                                                                                                                                                            TextMarshaler is a configurable text format marshaler.

                                                                                                                                                                                                                            func (*TextMarshaler) Marshal

                                                                                                                                                                                                                            func (tm *TextMarshaler) Marshal(w io.Writer, m Message) error

                                                                                                                                                                                                                              Marshal writes the proto text format of m to w.

                                                                                                                                                                                                                              func (*TextMarshaler) Text

                                                                                                                                                                                                                              func (tm *TextMarshaler) Text(m Message) string

                                                                                                                                                                                                                                Text returns a proto text formatted string of m.

                                                                                                                                                                                                                                type Unmarshaler

                                                                                                                                                                                                                                type Unmarshaler interface {
                                                                                                                                                                                                                                	// Unmarshal parses the encoded bytes of the protobuf wire input.
                                                                                                                                                                                                                                	// The provided buffer is only valid for during method call.
                                                                                                                                                                                                                                	// It should not reset the receiver message.
                                                                                                                                                                                                                                	Unmarshal([]byte) error
                                                                                                                                                                                                                                }

                                                                                                                                                                                                                                  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.

                                                                                                                                                                                                                                  type XXX_InternalExtensions

                                                                                                                                                                                                                                  type XXX_InternalExtensions = protoimpl.ExtensionFields

                                                                                                                                                                                                                                    Deprecated: Do not use; this is an internal type.