syntax ="proto3";package test.v1;import"google/protobuf/timestamp.proto";
option go_package ="goGinT/hello/proto/v1;test";
enum SexType {
MALE =0;
FEMALE =1;}
message Hello {string name =1;
message Result {string name =1;int32 age =2;}
Result data =2;
SexType sex =3;map<string,string> mapObj =4;
google.protobuf.Timestamp createTime =5;}
使用
package main
import("fmt"
test "goGinT/rpc/hello/protoc"
timestamppb "google.golang.org/protobuf/types/known/timestamppb")funcmain(){
helloInfo := test.Hello{
Name:"大壮",
Data:&test.Hello_Result{Name:"里斯", Age:12},
Sex: test.SexType_FEMALE,
MapObj:map[string]string{"title":"唐诗","age":"30"},
CreateTime: timestamppb.Now(),}
fmt.Println(&helloInfo)}