Skip to content
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

默认值会被encode #36

Closed
vontio opened this issue Jul 28, 2015 · 4 comments
Closed

默认值会被encode #36

vontio opened this issue Jul 28, 2015 · 4 comments

Comments

@vontio
Copy link

vontio commented Jul 28, 2015

一个类有10个字段,如果只使用了其中1个字段,其他9个字段 "应该" 不会encode.

@xiemalin
Copy link
Contributor

是的, 不用的字段,不加@protobuf注解就会忽略

@vontio
Copy link
Author

vontio commented Jul 28, 2015

10个optional字段,如果没有赋值,encode出来的bytes应该是空的.
对比了一下google实现的protobuf,如果直接newBuilder.Build encode出来是一个空bytes.

@xiemalin
Copy link
Contributor

google实现的protobuf 判空是需要 调用 hasxxx的方式,而不是根据值来判断的

@vontio
Copy link
Author

vontio commented Jul 29, 2015

是的,如果没有赋值,hasXXX == false 就不会encode

@xiemalin xiemalin closed this as completed Nov 9, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants