Comments (16)
You should use casttype instead of customtype.
This feature is available on the casttype branch
from protobuf.
Can casttype be made available before proto3?
from protobuf.
Also casttype doesn't work correctly - in proto2 syntax:
message RangeTreeNode {
optional bytes left_key = 4 [(gogoproto.casttype) = "Key"];
}
In the generated code, LeftKey
should be a pointer (because this thing is nullable) but it is not. Even the more explicit:
message RangeTreeNode {
optional bytes left_key = 4 [(gogoproto.nullable) = true, (gogoproto.casttype) = "Key"];
}
yields a value type rather than a pointer.
from protobuf.
casttype is not made for the bytes type.
"Changes the generated field type. It assumes that this type is castable to the original goprotobuf field type. It currently does not support byte slices, structs or enums."
If you have this usecase, maybe I should add this feature.
I was a little afraid, because I was getting sleepy and was a little worried about the side effects of just casting to a type if that type does not imply a copy.
For bytes I still recommend customtype, but I could add this feature if you think it would be useful?
from protobuf.
I am thinking about merging proto3 back into master before proto3 is officially released, but I don't know yet.
golang/protobuf does not have a problem with merging their proto3 support into their master branch, so I guess I should ask myself what I am afraid of.
I'll have to run some more tests first.
I think it would be really great to launch the gofast feature on the master branch.
Why would you want this feature in master asap?
from protobuf.
Ok I ran some tests. It all looks good.
I merged proto3 into master.
from protobuf.
If I make casttype work for bytes as well. Their is a problem in proto/text which is very easy to fix, but their is another problem in encoding/json
from protobuf.
This issue is now a duplicate of #36.
from protobuf.
This is the issue with bytes as a casttype.
http://play.golang.org/p/RXlhj9_ld5
from protobuf.
Do you have any ideas, maybe some annotation, that could fix this?
from protobuf.
I think in this case (our type is an alias for []byte
) we should use
casttype and the Marshal/Unmarshal/Size/whatever implementations should be
generated to cast to []byte
internally. What do you think?
On Jun 6, 2015 11:23 AM, "Walter Schulze" [email protected] wrote:
Do you have any ideas, maybe some annotation, that could fix this?
—
Reply to this email directly or view it on GitHub
#58 (comment).
from protobuf.
How does that solve the json problem?
from protobuf.
http://play.golang.org/p/l9N7d3SPc0
from protobuf.
Of course :)
Ok but it was not quite there
http://play.golang.org/p/Hpb0FEssL6
from protobuf.
Ok the casttype branch should now support bytes as a casttype.
from protobuf.
Please reopen this issue it the problem still occurs.
from protobuf.
Related Issues (20)
- panic: protobuf tag not enough fields in Empty.state HOT 1
- Enum filling with negative numbers will report an error, is it the Enum that does not support negative numbers?
- License question
- protoreflect
- Vulnerability?
- Panic: invalid Go type HOT 3
- github.com/gogo/protobuf is not installed
- Improper Input Validation in GoGo Protobuf HOT 1
- string time and duration
- oom
- Panic: reflect: Elem of invalid type HOT 1
- How to customize the name of an enumeration value, using the extension `enumvalue_customname ` seems unable to complete.
- m argument not work
- Call command.Generate(req *plugin.CodeGeneratorRequest) twice could cause bug.
- BUG: protoc-gen-gogofast not generate trailing comments
- How to generate parameter "description" in message of proto3 HOT 1
- proto: protect field access with lock to avoid possible data race
- proto: protect field access with lock to avoid possible data race
- Release v1.3.3 - Please please please create it pointing to v1.3.2
- Unsafe type assertion
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from protobuf.