Reputation: 362
I am trying to use gRPC and using the exchange message format as protobuf. I wanted to add timestamp field inside my message.But i don't know the right way to add the import statement in proto file. I am using Golang so I need an output as .pb.go
Upvotes: 18
Views: 36961
Reputation: 429
Make sure to import in your proto file:
import "google/protobuf/timestamp.proto";
And use the type for you variable like:
google.protobuf.Timestamp time_name = 1;
Upvotes: 36
Reputation: 26394
In your proto file:
import "google/protobuf/timestamp.proto"
Based on the documentation, that should be all that's necessary.
Upvotes: 2
Reputation: 6628
You can import timestamp from the ptypes package: in the standard Go Protobuf repo.
import (
"github.com/golang/protobuf/ptypes/timestamp"
)
Upvotes: 0
Reputation: 7411
Grpc does not have a timestamp AFAIK.
I usually use the Unix Epoch - the go function
Unix(sec int64, nsec int64)
and
func (t Time) Unix() int64
is your fried
Upvotes: -1