pbutil

package module
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2021 License: MIT Imports: 9 Imported by: 0

README

pbtime

some utils on protobuf v3, likes well-known types Timestamp and Duration.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDuration

func NewDuration(d time.Duration) *durationpb.Duration

NewDuration create protobuf duration by time.Duration

func NewTimestamp

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

NewTimestamp create protobuf timestamp by time.Time

func ParseDuration

func ParseDuration(duration *durationpb.Duration) (time.Duration, error)

ParseDuration get time.Duration from protobuf duration

func ParseTimestamp

func ParseTimestamp(timestamp *timestamppb.Timestamp, location ...*time.Location) (*time.Time, error)

ParseTimestamp get time.Time from protobuf timestamp

func ProtoMessage2JSON

func ProtoMessage2JSON(message proto.Message) (string, error)

ProtoMessage2JSON marshal protobuf message to json string

func ProtoMessage2Map

func ProtoMessage2Map(message proto.Message) (map[string]interface{}, error)

ProtoMessage2Map marshal protobuf message to map[string]interface{}

Types

This section is empty.

Jump to

Keyboard shortcuts

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