I have a proto file:
syntax = "proto3";
package main;
message Client {
int32 Id = 1;
string Name = 2;
string Email = 3;
}
The compiled Client
struct like below:
type Client struct {
Id int32 `protobuf:"varint,1,opt,name=Id,proto3" json:"Id,omitempty"`
Name string `protobuf:"bytes,2,opt,name=Name,proto3" json:"Name,omitempty"`
Email string `protobuf:"bytes,3,opt,name=Email,proto3" json:"Email,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
When I am trying to init this Client
struct like below:
client := &Client{123, "John", "john@aol.com"}
I am getting building error: too few values in struct initializer
. I found a way to fix it by adding XXX_NoUnkeyedLiteral
, XXX_unrecognized
, XXX_sizecache
. I don't know what these are, and wondering if this is the right way to do it:
client := &Client{123, "John", "john@aol.com", struct{}{}, []byte{}, int32(0)}