如何在GoProtobuff中获得具体类型(而不是指针)的切片
对于原始文件:如何在GoProtobuff中获得具体类型(而不是指针)的切片,go,protocol-buffers,Go,Protocol Buffers,对于原始文件: syntax = "proto3"; package messagepb; import "github.com/gogo/protobuf/gogoproto/gogo.proto"; option (gogoproto.marshaler_all) = true; option (gogoproto.sizer_all) = true; option (gogoproto.unmarshaler_all) = true; option (gogoproto.goproto
syntax = "proto3";
package messagepb;
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
option (gogoproto.marshaler_all) = true;
option (gogoproto.sizer_all) = true;
option (gogoproto.unmarshaler_all) = true;
option (gogoproto.goproto_getters_all) = false;
service KV {
// Put puts the given key into the store.
// A put request increases the revision of the store,
// and generates one event in the event history.
rpc Put(PutRequest) returns (PutResponse) {}
}
message PutRequest {
bytes key = 1;
bytes value = 2;
}
message ResponseHeader {
repeated PutRequest l = 3;
}
我得到以下原型结构:
type ResponseHeader struct {
L []*PutRequest `protobuf:"bytes,3,rep,name=l" json:"l,omitempty"`
}
但如何获得以下原型结构:
type ResponseHeader struct {
L []PutRequest `protobuf:"bytes,3,rep,name=l" json:"l,omitempty"`
}
也就是说,我希望有数据局部性(因此是重叠数据的切片,而不是散开数据的指针)我需要使用:[(gogoproto.nullable)=false]
例如:
得到:
L []PutRequest `protobuf:"bytes,3,rep,name=l" json:"l"`
是的,我问了这个问题,然后在几个小时后找到了答案
L []PutRequest `protobuf:"bytes,3,rep,name=l" json:"l"`