How to store time in protobuf 3

2.6k Views Asked by At

I have this struct in golang

struct File {
  name string
  creatation_time time.Time
}

How do I write it in protobuf3 ?

1

There are 1 best solutions below

2
On

Create example.proto;

syntax = "proto3";

import google_protobuf "github.com/golang/protobuf/ptypes/timestamp"

message File {
    string name = 1;
    google.protobuf.Timestamp creatation_time = 2;  
}

After compilation check the example.pb.go for the structure definition that has been created.