ptypes

package
v0.0.0-...-f0983eb Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2016 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package ptypes is a copy of the golang/protobuf/ptypes that we'll need to use with our regenerated ptypes until google gets their act together and makes their "Well Known Types" actually usable by other parties.

It is more likely that this issue will be resolved by gogo.

Note that this is not a vendoring of the package. We have to change the types to match the generated types.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Duration

func Duration(p *durpb.Duration) (time.Duration, error)

Duration converts a durpb.Duration to a time.Duration. Duration returns an error if the durpb.Duration is invalid or is too large to be represented in a time.Duration.

func DurationProto

func DurationProto(d time.Duration) *durpb.Duration

DurationProto converts a time.Duration to a durpb.Duration.

func MustTimestampProto

func MustTimestampProto(t time.Time) *tspb.Timestamp

MustTimestampProto converts time.Time to a google.protobuf.Timestamp proto. It panics if input timestamp is invalid.

func Timestamp

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

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

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

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

func TimestampProto

func TimestampProto(t time.Time) (*tspb.Timestamp, error)

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

func TimestampString

func TimestampString(ts *tspb.Timestamp) string

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

Types

This section is empty.

Jump to

Keyboard shortcuts

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