英文:
package to encapsulate float64 in protobuf
问题
我正在使用Stripe创建订阅的微服务中工作。其中一个字段在.proto文件中被设置为float,但它被转换为float32而不是float64。
我无法找到直接的方法让protobuf生成一个字段类型为float64的文件。有人可以帮我吗?是否有专门用于protobuf的包可以封装float64类型?
非常感谢!
英文:
I was working in a microservice to create subscriptions in Stripe. One of the fields is listed as a float64 where I set it up as a float in the .proto file. This cast the field as a float32 not float64.
I cannot see a direct way to make protobuf to produce a file with the field typed as float64. Can someone help me here? Is there any special package for protobuf that encapsulates a float64?
Many Thanks
答案1
得分: 11
如在标量值类型中提到的那样,Go中的float64在protobuf中使用double进行定义。因此,你需要将代码从:
float a_field = 1;
修改为:
double a_field = 1;
英文:
As mentioned in Scalar Value Types, float64 in Go is defined with double in protobuf. So instead of writing:
float a_field = 1;
you will write:
double a_field = 1;
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论