ptypes
packageThis package is not in the latest version of its module.
Details
Validgo.mod file
The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable license
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Tagged version
Modules with tagged versions give importers more predictable builds.
Stable version
When a project reaches major version v1 it is considered stable.
- Learn more about best practices
Repository
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¶
- func AnyMessageName(any *anypb.Any) (string, error)deprecated
- func Duration(dur *durationpb.Duration) (time.Duration, error)deprecated
- func DurationProto(d time.Duration) *durationpb.Durationdeprecated
- func Empty(any *anypb.Any) (proto.Message, error)deprecated
- func Is(any *anypb.Any, m proto.Message) booldeprecated
- func MarshalAny(m proto.Message) (*anypb.Any, error)deprecated
- func Timestamp(ts *timestamppb.Timestamp) (time.Time, error)deprecated
- func TimestampNow() *timestamppb.Timestampdeprecated
- func TimestampProto(t time.Time) (*timestamppb.Timestamp, error)deprecated
- func TimestampString(ts *timestamppb.Timestamp) stringdeprecated
- func UnmarshalAny(any *anypb.Any, m proto.Message) errordeprecated
- type DynamicAnydeprecated
Constants¶
This section is empty.
Variables¶
This section is empty.
Functions¶
funcAnyMessageNamedeprecated
funcDurationProtodeprecated
func DurationProto(dtime.Duration) *durationpb.Duration
DurationProto converts a time.Duration to a durationpb.Duration.
Deprecated: Call the durationpb.New function instead.
funcEmptydeprecated
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.
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
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
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)ProtoMessage¶added inv1.4.0
func (mDynamicAny) ProtoMessage()
func (DynamicAny)ProtoReflect¶added inv1.4.0
func (mDynamicAny) ProtoReflect()protoreflect.Message
func (DynamicAny)Reset¶added inv1.4.0
func (mDynamicAny) Reset()
func (DynamicAny)String¶added inv1.4.0
func (mDynamicAny) String()string