2017-02-22 80 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