New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Why has methods are not generated using protoc 3.17.* if in protobuf repo they say it should? #1336
Comments
The In the proto3 standard, a non-present field is equivalent to a zero value which is equivalent to a non-present field. (Some exceptions apply, e.g. an empty Message is not the same as a not-appearing Message.) I also see that you have the |
They talk about proto3, maybe they are wrong? You're right. But my question is if I'm using it well or am I wrong (if empty is valid value)? |
That doc is wrong. There are no Rewriting those examples correctly:
|
The documentation on https://github.com/protocolbuffers/protobuf/blob/master/docs/field_presence.md#go-example is incorrect. Using "optional" in proto3 makes the field be generated just as it would in proto2. |
PR to fix that doc: |
Ick, I didn’t even notice the other minor As the others noted the example code was wrong; and after looking at the history of the file and the PR itself, it looks like the original was itself an assumption on how the Go code would work. |
What beautiful people you are! Thanks for all the advice! |
Reading here: https://github.com/protocolbuffers/protobuf/blob/master/docs/field_presence.md#go-example the Golang example:
if I use:
with:
it doesn't generate any
has<T>()
method.Why?
Am I wrong if I use
MyPlayer
generated proto fields instead of methods?Example:
instead of
which is not what I want (I want to detect nil values).
The text was updated successfully, but these errors were encountered: