package protobuf import ( "github.com/golang/protobuf/ptypes" "github.com/golang/protobuf/ptypes/timestamp" "log" "time" ) func MarshalTime(t time.Time) *timestamp.Timestamp { pt, err := ptypes.TimestampProto(t) if err != nil { log.Printf("time to proto time error: %v", err) } return pt } func UnMarshalTime(pt *timestamp.Timestamp) *time.Time { t, err := ptypes.Timestamp(pt) if err != nil { log.Printf("time to proto time error: %v", err) } return &t }