Movatterモバイル変換


[0]ホーム

URL:


dynamicpb

package
v1.36.11Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 12, 2025 License:BSD-3-ClauseImports:10Imported by:440

Details

Repository

github.com/protocolbuffers/protobuf-go

Links

Documentation

Overview

Package dynamicpb creates protocol buffer messages using runtime type information.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

funcNewEnumTypeadded inv1.25.0

NewEnumType creates a new EnumType with the provided descriptor.

EnumTypes created by this package are equal if their descriptors are equal.That is, if ed1 == ed2, then NewEnumType(ed1) == NewEnumType(ed2).

Enum values created by the EnumType are equal if their numbers are equal.

funcNewExtensionType

NewExtensionType creates a new ExtensionType with the provided descriptor.

Dynamic ExtensionTypes with the same descriptor compare as equal. That is,if xd1 == xd2, then NewExtensionType(xd1) == NewExtensionType(xd2).

The InterfaceOf and ValueOf methods of the extension type are defined as:

func (xt extensionType) ValueOf(iv any) protoreflect.Value {return protoreflect.ValueOf(iv)}func (xt extensionType) InterfaceOf(v protoreflect.Value) any {return v.Interface()}

The Go type used by the proto.GetExtension and proto.SetExtension functionsis determined by these methods, and is therefore equivalent to the Go typeused to represent a protoreflect.Value. See the protoreflect.Valuedocumentation for more details.

funcNewMessageType

NewMessageType creates a new MessageType with the provided descriptor.

MessageTypes created by this package are equal if their descriptors are equal.That is, if md1 == md2, then NewMessageType(md1) == NewMessageType(md2).

Types

typeMessage

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

A Message is a dynamically constructed protocol buffer message.

Message implements thegoogle.golang.org/protobuf/proto.Message interface,and may be used with all standard proto package functionssuch as Marshal, Unmarshal, and so forth.

Message also implements theprotoreflect.Message interface.See theprotoreflect package documentation for that interface for how toget and set fields and otherwise interact with the contents of a Message.

Reflection API functions which construct messages, such as NewField,return new dynamic messages of the appropriate type. Functions which takemessages, such as Set for a message-value field, will accept any messagewith a compatible type.

Operations which modify a Message are not safe for concurrent use.

funcNewMessage

func NewMessage(descprotoreflect.MessageDescriptor) *Message

NewMessage creates a new message with the provided descriptor.

func (*Message)Clear

Clear clears a field.Seeprotoreflect.Message for details.

func (*Message)Descriptor

func (m *Message) Descriptor()protoreflect.MessageDescriptor

Descriptor returns the message descriptor.

func (*Message)Get

Get returns the value of a field.Seeprotoreflect.Message for details.

func (*Message)GetUnknown

func (m *Message) GetUnknown()protoreflect.RawFields

GetUnknown returns the raw unknown fields.Seeprotoreflect.Message for details.

func (*Message)Has

Has reports whether a field is populated.Seeprotoreflect.Message for details.

func (*Message)Interface

func (m *Message) Interface()protoreflect.ProtoMessage

Interface returns the message.Seeprotoreflect.Message for details.

func (*Message)IsValid

func (m *Message) IsValid()bool

IsValid reports whether the message is valid.Seeprotoreflect.Message for details.

func (*Message)Mutable

Mutable returns a mutable reference to a repeated, map, or message field.Seeprotoreflect.Message for details.

func (*Message)New

New returns a newly allocated empty message with the same descriptor.Seeprotoreflect.Message for details.

func (*Message)NewField

NewField returns a new value for assignable to the field of a given descriptor.Seeprotoreflect.Message for details.

func (*Message)ProtoMessageadded inv1.21.0

func (m *Message) ProtoMessage()

ProtoMessage implements the legacy message interface.

func (*Message)ProtoMethods

func (m *Message) ProtoMethods() *protoiface.Methods

ProtoMethods is an internal detail of theprotoreflect.Message interface.Users should never call this directly.

func (*Message)ProtoReflect

func (m *Message) ProtoReflect()protoreflect.Message

ProtoReflect implements theprotoreflect.ProtoMessage interface.

func (*Message)Range

Range visits every populated field in undefined order.Seeprotoreflect.Message for details.

func (*Message)Resetadded inv1.21.0

func (m *Message) Reset()

Reset clears the message to be empty, but preserves the dynamic message type.

func (*Message)Set

Set stores a value in a field.Seeprotoreflect.Message for details.

func (*Message)SetUnknown

func (m *Message) SetUnknown(rprotoreflect.RawFields)

SetUnknown sets the raw unknown fields.Seeprotoreflect.Message for details.

func (*Message)String

func (m *Message) String()string

String returns a string representation of a message.

func (*Message)Type

Type returns the message type.

func (*Message)WhichOneof

WhichOneof reports which field in a oneof is populated, returning nil if none are populated.Seeprotoreflect.Message for details.

typeTypesadded inv1.31.0

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

A Types is a collection of dynamically constructed descriptors.Its methods are safe for concurrent use.

Types implementsprotoregistry.MessageTypeResolver andprotoregistry.ExtensionTypeResolver.A Types may be used as agoogle.golang.org/protobuf/proto.UnmarshalOptions.Resolver.

funcNewTypesadded inv1.31.0

func NewTypes(f *protoregistry.Files) *Types

NewTypes creates a new Types registry with the provided files.The Files registry is retained, and changes to Files will be reflected in Types.It is not safe to concurrently change the Files while calling Types methods.

func (*Types)FindEnumByNameadded inv1.31.0

func (t *Types) FindEnumByName(nameprotoreflect.FullName) (protoreflect.EnumType,error)

FindEnumByName looks up an enum by its full name;e.g., "google.protobuf.Field.Kind".

This returns (nil,protoregistry.NotFound) if not found.

func (*Types)FindExtensionByNameadded inv1.31.0

func (t *Types) FindExtensionByName(nameprotoreflect.FullName) (protoreflect.ExtensionType,error)

FindExtensionByName looks up an extension field by the field's full name.Note that this is the full name of the field as determined bywhere the extension is declared and is unrelated to the full name of themessage being extended.

This returns (nil,protoregistry.NotFound) if not found.

func (*Types)FindExtensionByNumberadded inv1.31.0

func (t *Types) FindExtensionByNumber(messageprotoreflect.FullName, fieldprotoreflect.FieldNumber) (protoreflect.ExtensionType,error)

FindExtensionByNumber looks up an extension field by the field numberwithin some parent message, identified by full name.

This returns (nil,protoregistry.NotFound) if not found.

func (*Types)FindMessageByNameadded inv1.31.0

func (t *Types) FindMessageByName(nameprotoreflect.FullName) (protoreflect.MessageType,error)

FindMessageByName looks up a message by its full name;e.g. "google.protobuf.Any".

This returns (nil,protoregistry.NotFound) if not found.

func (*Types)FindMessageByURLadded inv1.31.0

func (t *Types) FindMessageByURL(urlstring) (protoreflect.MessageType,error)

FindMessageByURL looks up a message by a URL identifier.See documentation on google.protobuf.Any.type_url for the URL format.

This returns (nil,protoregistry.NotFound) if not found.

Source Files

View all Source files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp