I have a time.Time variable in Golang 10-30 00:49:07.1236 that needs to be converted to a Go Protobuf timestamp.Timestamp. Any idea on what functions can be used to accomplish this? Or am I looking at this from the wrong angle?
I have a time.Time variable in Golang 10-30 00:49:07.1236 that needs to be converted to a Go Protobuf timestamp.Timestamp. Any idea on what functions can be used to accomplish this? Or am I looking at this from the wrong angle?
See New and Timestamp.AsTime in timestamppb
These support conversion to/from time.Time and Timestamp
Below code will give current time in timestamppb format
import "google.golang.org/protobuf/types/known/timestamppb"
timeNow := timestamppb.Now()
Below will return time in time.Time format
timeNow.GetCurrentTime().AsTime()