protoutil

package
v1.20210103.1 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const TypeURLPrefix = "type.googleapis.com/"

TypeURLPrefix is the type url prefix for type urls.

Variables

This section is empty.

Functions

func Any

func Any(msg proto.Message) (*any.Any, error)

Any packs a message as an Any.

func Duration

func Duration(d time.Duration) *duration.Duration

Duration returns a proto duration.

func FromAny

func FromAny(m *any.Any) (proto.Message, error)

FromAny unpacks a message any into a type message.

func FromDuration

func FromDuration(dur *duration.Duration) time.Duration

FromDuration returns a time.Duration.

func FromTimestamp

func FromTimestamp(t *timestamp.Timestamp) time.Time

FromTimestamp returns a time.Time.

NOTE: protobuf timestamps are always transmitted as UTC.

func FromTypeURL

func FromTypeURL(typeURL string) (proto.Message, error)

FromTypeURL returns a message from the global types proto registry.

func MessageTypeFromTypeURL

func MessageTypeFromTypeURL(typeURL string) string

MessageTypeFromTypeURL returns the message type from a given any type url.

func MessageTypeName

func MessageTypeName(msg proto.Message) string

MessageTypeName returns the message type name for a given message.

func Timestamp

func Timestamp(t time.Time) *timestamp.Timestamp

Timestamp returns a proto timestamp.

NOTE: protobuf timestamps are always transmitted as UTC.

func TypeURL

func TypeURL(msg proto.Message) string

TypeURL returns the typeURL for a given message.

The bulk of this method was lifted from the anypb source.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL