thanhpk
thanhpk

Reputation: 4297

How to store time in protobuf 3

I have this struct in golang

struct File {
  name string
  creatation_time time.Time
}

How do I write it in protobuf3 ?

Upvotes: 5

Views: 2692

Answers (1)

Guirish Salgaonkar
Guirish Salgaonkar

Reputation: 86

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.

Upvotes: 4

Related Questions