Movatterモバイル変換


[0]ホーム

URL:


Warning Deprecated: Use the "google.golang.org/protobuf" module instead.

ptypes

package
v1.5.4Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2024 License:BSD-3-ClauseImports:10Imported by:9,804

Details

Repository

github.com/golang/protobuf

Links

Documentation

Overview

Package ptypes provides functionality for interacting with well-known types.

Deprecated: Well-known types have specialized functionality directlyinjected into the generated packages for each message type.See the deprecation notice for each function for the suggested alternative.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

funcAnyMessageNamedeprecated

func AnyMessageName(any *anypb.Any) (string,error)

AnyMessageName returns the message name contained in an anypb.Any message.Most type assertions should use the Is function instead.

Deprecated: Call the any.MessageName method instead.

funcDurationdeprecated

func Duration(dur *durationpb.Duration) (time.Duration,error)

Duration converts a durationpb.Duration to a time.Duration.Duration returns an error if dur is invalid or overflows a time.Duration.

Deprecated: Call the dur.AsDuration and dur.CheckValid methods instead.

funcDurationProtodeprecated

func DurationProto(dtime.Duration) *durationpb.Duration

DurationProto converts a time.Duration to a durationpb.Duration.

Deprecated: Call the durationpb.New function instead.

funcEmptydeprecated

func Empty(any *anypb.Any) (proto.Message,error)

Empty returns a new message of the type specified in an anypb.Any message.It returns protoregistry.NotFound if the corresponding message type could notbe resolved in the global registry.

Deprecated: Use protoregistry.GlobalTypes.FindMessageByName insteadto resolve the message name and create a new instance of it.

funcIsdeprecated

func Is(any *anypb.Any, mproto.Message)bool

Is reports whether the Any message contains a message of the specified type.

Deprecated: Call the any.MessageIs method instead.

funcMarshalAnydeprecated

func MarshalAny(mproto.Message) (*anypb.Any,error)

MarshalAny marshals the given message m into an anypb.Any message.

Deprecated: Call the anypb.New function instead.

funcTimestampdeprecated

func Timestamp(ts *timestamppb.Timestamp) (time.Time,error)

Timestamp converts a timestamppb.Timestamp to a time.Time.It returns an error if the argument is invalid.

Unlike most Go functions, if Timestamp returns an error, the first returnvalue is not the zero time.Time. Instead, it is the value obtained from thetime.Unix function when passed the contents of the Timestamp, in the UTClocale. This may or may not be a meaningful time; many invalid Timestampsdo map to valid time.Times.

A nil Timestamp returns an error. The first return value in that case isundefined.

Deprecated: Call the ts.AsTime and ts.CheckValid methods instead.

funcTimestampNowdeprecated

func TimestampNow() *timestamppb.Timestamp

TimestampNow returns a google.protobuf.Timestamp for the current time.

Deprecated: Call the timestamppb.Now function instead.

funcTimestampProtodeprecated

func TimestampProto(ttime.Time) (*timestamppb.Timestamp,error)

TimestampProto converts the time.Time to a google.protobuf.Timestamp proto.It returns an error if the resulting Timestamp is invalid.

Deprecated: Call the timestamppb.New function instead.

funcTimestampStringdeprecated

func TimestampString(ts *timestamppb.Timestamp)string

TimestampString returns theRFC 3339 string for valid Timestamps.For invalid Timestamps, it returns an error message in parentheses.

Deprecated: Call the ts.AsTime method instead,followed by a call to the Format method on the time.Time value.

funcUnmarshalAnydeprecated

func UnmarshalAny(any *anypb.Any, mproto.Message)error

UnmarshalAny unmarshals the encoded value contained in the anypb.Any messageinto the provided message m. It returns an error if the target messagedoes not match the type in the Any message or if an unmarshal error occurs.

The target message m may be a *DynamicAny message. If the underlying messagetype could not be resolved, then this returns protoregistry.NotFound.

Deprecated: Call the any.UnmarshalTo method instead.

Types

typeDynamicAnydeprecated

type DynamicAny struct{proto.Message }

DynamicAny is a value that can be passed to UnmarshalAny to automaticallyallocate a proto.Message for the type specified in an anypb.Any message.The allocated message is stored in the embedded proto.Message.

Example:

var x ptypes.DynamicAnyif err := ptypes.UnmarshalAny(a, &x); err != nil { ... }fmt.Printf("unmarshaled message: %v", x.Message)

Deprecated: Use the any.UnmarshalNew method instead to unmarshalthe any message contents into a new instance of the underlying message.

func (DynamicAny)ProtoMessageadded inv1.4.0

func (mDynamicAny) ProtoMessage()

func (DynamicAny)ProtoReflectadded inv1.4.0

func (mDynamicAny) ProtoReflect()protoreflect.Message

func (DynamicAny)Resetadded inv1.4.0

func (mDynamicAny) Reset()

func (DynamicAny)Stringadded inv1.4.0

func (mDynamicAny) String()string

Source Files

View all Source files

Directories

PathSynopsis

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