-
Notifications
You must be signed in to change notification settings - Fork 385
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
proto3怎么区分默认值和缺省值呢? #239
Labels
Comments
你试试最新的master的版本,我这边是OK的: local pb = require "pb"
local slice = require "pb.slice"
local buffer = require "pb.buffer"
local protoc = require "protoc"
local serpent = require "serpent"
local parser = protoc.new()
parser.proto3_optional = true
parser:load [[
syntax = "proto3";
message Test {
optional uint32 foo = 1;
}
]]
print(serpent.block(pb.decode("Test", pb.encode("Test", {}))))
print(serpent.block(pb.decode("Test", pb.encode("Test", {foo = 0})))) 输出:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
在设置pb.option("no_default_values")的情况下,无论是没赋值还是赋的默认值,decode出来都是nil,请问怎么区分呢?
另,试了
local parser = protoc.new();
parser.proto3_optional = true
之后在proto3中加入 optional 依然报错
The text was updated successfully, but these errors were encountered: