草庐IT

protobuf-LiteralByteString

全部标签

go - 如何在 protobuf3 中存储 time.duration

在原型(prototype)文件中...syntax="proto3";import"google/protobuf/duration.proto";messageaaaResponse{google.protobuf.Durationmin=2;}...将自动生成*duration.Duration如何修改proto文件获取time.Duration 最佳答案 试试这个:gogetgithub.com/gogo/protobuf/protoc-gen-gogofasterprotoc--gogofaster_out=./durat

json - 如何使用 jsonpb 将 JSON 解码为包含一个定义的 protobuf?

我目前无法解码jsonpb生成的JSON片段。也许这只是我的某种误解,但在查看测试时我希望它能以某种方式工作。这是pb.proto的相关片段:syntax="proto3";packagepb;messageParameter{stringname=1;oneofvalue{stringstr_value=2;int32int_value=3;boolbool_value=4;floatfloat_value=5;}}messageParameterSet{bytesraw=1;repeatedParameterparameters=2;}messageParameterSets{ma

json - 如何使用 jsonpb 将 JSON 解码为包含一个定义的 protobuf?

我目前无法解码jsonpb生成的JSON片段。也许这只是我的某种误解,但在查看测试时我希望它能以某种方式工作。这是pb.proto的相关片段:syntax="proto3";packagepb;messageParameter{stringname=1;oneofvalue{stringstr_value=2;int32int_value=3;boolbool_value=4;floatfloat_value=5;}}messageParameterSet{bytesraw=1;repeatedParameterparameters=2;}messageParameterSets{ma

go - 如何在 Go 中设置/获取 protobuf 的扩展字段?

我是一名Go语言开发人员。我们的团队选择使用ProtocolBuffer来转换数据。我选择了这个protobuf包:https://github.com/golang/protobuf.但是,这个包没有方法来处理ProtocolBuffer中的extensions字段。我只在protoc生成的类文件中找到了这段代码:varE_Height=&proto.ExtensionDesc{ExtendedType:(*Person)(nil),ExtensionType:(*int32)(nil),Field:110,Name:"eg.Height",Tag:"varint,110,opt",

go - 如何在 Go 中设置/获取 protobuf 的扩展字段?

我是一名Go语言开发人员。我们的团队选择使用ProtocolBuffer来转换数据。我选择了这个protobuf包:https://github.com/golang/protobuf.但是,这个包没有方法来处理ProtocolBuffer中的extensions字段。我只在protoc生成的类文件中找到了这段代码:varE_Height=&proto.ExtensionDesc{ExtendedType:(*Person)(nil),ExtensionType:(*int32)(nil),Field:110,Name:"eg.Height",Tag:"varint,110,opt",

go - 为 protobuf 消息字段定义自定义 go struct 标签

我是grpc的新手,一直在尝试从网络服务器获取json响应。然后stub可以从rpc服务器请求json。在我的.proto文件中,我创建了一个消息类型:messagePost{int64number=1;stringnow=2;stringname=3;}但是我无法编码number字段,因为protoc会生成带有number的结构pb.go文件标签:{"no":"23","now":"12:06:46","name":"bob"}我怎样才能强制Message使用消息字段的小写名称以外的标记进行“转换”?比如使用json标签no,即使Message中的字段名是number。

go - 为 protobuf 消息字段定义自定义 go struct 标签

我是grpc的新手,一直在尝试从网络服务器获取json响应。然后stub可以从rpc服务器请求json。在我的.proto文件中,我创建了一个消息类型:messagePost{int64number=1;stringnow=2;stringname=3;}但是我无法编码number字段,因为protoc会生成带有number的结构pb.go文件标签:{"no":"23","now":"12:06:46","name":"bob"}我怎样才能强制Message使用消息字段的小写名称以外的标记进行“转换”?比如使用json标签no,即使Message中的字段名是number。

go - 如何使用 google.protobuf.timestamp 和 cassandra

我正在使用“google/protobuf/timestamp.proto”在golang结构中定义时间戳类型:import"google/protobuf/timestamp.proto";messageUser{stringid=1;...google.protobuf.Timestampcreated_at=12;google.protobuf.Timestampupdated_at=13;google.protobuf.Timestamplast_login=14;}当使用cqlx插入到cassandra时:req.CreatedAt=ptypes.TimestampNow()

go - 如何使用 google.protobuf.timestamp 和 cassandra

我正在使用“google/protobuf/timestamp.proto”在golang结构中定义时间戳类型:import"google/protobuf/timestamp.proto";messageUser{stringid=1;...google.protobuf.Timestampcreated_at=12;google.protobuf.Timestampupdated_at=13;google.protobuf.Timestamplast_login=14;}当使用cqlx插入到cassandra时:req.CreatedAt=ptypes.TimestampNow()

go - Protobuf、Go 和私有(private)字段

假设我在我的.proto文件中定义了一个Player。messagePlayer{stringfirst_name=1;stringlast_name=2;int32user_id=3;}我正在使用https://github.com/twitchtv/twirp在我的Go后端和我的JavaScript前端之间进行通信。如果您不知道Twirp,它只是HTTP1.1上的JSONRPC。Player消息被转换为Go结构typePlayerstruct{FirstNamestringLastNamestringUserIdint32}众所周知,大写字段是公开的。但是我想将UserId保密,即