[英]How to get slice of concrete type (not pointers) in go protobuff
For protofile: 对于protofile:
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;
}
I get the following proto struct: 我得到以下proto结构:
type ResponseHeader struct {
L []*PutRequest `protobuf:"bytes,3,rep,name=l" json:"l,omitempty"`
}
But how do I get following protostruct: 但是我如何获得以下protostruct:
type ResponseHeader struct {
L []PutRequest `protobuf:"bytes,3,rep,name=l" json:"l,omitempty"`
}
That is I want having data locality (and thus slices of contig data, not pointers to spread out stuff) 那就是我想拥有数据局部性(因此需要切片重叠数据,而不是指向展开的东西)
I needed to use: [(gogoproto.nullable) = false] as in: 我需要使用:[(gogoproto.nullable)= false],如:
repeated PutRequest l = 3 [(gogoproto.nullable) = false];
And got: 得到了:
L []PutRequest `protobuf:"bytes,3,rep,name=l" json:"l"`
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.