fixed icon indicating copy to clipboard operation
fixed copied to clipboard

protobuf friendly

Open k1ng440 opened this issue 6 years ago • 9 comments

it would be awesome if we can use it with Protobuf.

k1ng440 avatar Feb 03 '19 06:02 k1ng440

I’ll look into it. The go-trader uses doubles in grpc - which is not really correct - for ease of development at the time. So it would be a worthwhile change.

robaho avatar Feb 03 '19 16:02 robaho

A big problem is the protobufs is cross platform, so the only reasonable way would be to encode as strings, but have the Go Marshall to/from fixed.

robaho avatar Feb 03 '19 16:02 robaho

please check this protobuf

https://github.com/googleapis/googleapis/blob/master/google/type/money.proto

k1ng440 avatar Feb 03 '19 17:02 k1ng440

Yes, but my initial reading shows that to make it work you need either built in support by Google for the type, or you have to treat it as a struct, which a Fixed is not. I don’t see any easy way to do a custom Marshall like with Json.

robaho avatar Feb 03 '19 17:02 robaho

See this https://github.com/protocolbuffers/protobuf/issues/2483

robaho avatar Feb 03 '19 17:02 robaho

It looks like you would have to call a to/from method for every field access.

robaho avatar Feb 03 '19 17:02 robaho

Which would also then require exposing read and write access to the internal long. But it would be better than encoding as string since it would be more efficient.

robaho avatar Feb 03 '19 17:02 robaho

please read this helper library for timestamp https://github.com/golang/protobuf/blob/master/ptypes/timestamp.go

k1ng440 avatar Feb 03 '19 17:02 k1ng440

@k1ng440 I understand, but if you notice Timestamp is an approved 'known type' by the protobufs project and that is why it is directly (and easily) supported.

protobufs would need to declare a "fixed place" decimal to allow fixed.Fixed to work as easily.

robaho avatar Feb 03 '19 19:02 robaho

closing this as infeasible

robaho avatar Sep 09 '22 03:09 robaho