2017-02-22 32 views

回答

1

創建example.proto;

syntax = "proto3"; 

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

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

編譯後檢查已創建的結構定義的example.pb.go。

+0

您使用的是哪個版本的protoc?我是libprotoc 3.0.0,我必須導入「github.com/golang/protobuf/ptypes/timestamp/timestamp.proto」,它也給我* google_protobuf.Timestamp不是golang的標準時間。 – thanhpk