Open yanglgtm opened 8 years ago
是parser.lua的问题,其中的function _fix_field(namespace , field, all),云风原来只判断是个复合类型,才会去解析default(放在了函数后面),由于云风不再维护PBC了,可以自行修改下,比如
local function _fix_field(namespace , field, all)
local options = field.options
if options then
if options.default then
field.default_value = tostring(options.default)
options.default = nil
end
if next(options) == nil then
field.options = nil
end
end
local type_name = field.type_name
if type_name == "" then
field.type_name = nil
return
elseif type_name == nil then
return
end
local full_name = assert(_match_name(namespace, field.type_name, all) , field.type_name , all)
field.type_name = full_name
field.type = all[full_name]
end
让default的解析优先即可
@lf723 非常感谢,我这边已经换用 protoc-gen-lua 这个库了,也有坑,不过都填上了。。
我在 openresty里使用 pbc,注册 pb 文件(执行parser.register)的时候报错,版本是lua 5.1。我用wiki 里的测试 pb 文件(addressbook.proto)是没问题的。
下面是 pb 文件。我尝试将ReqBody和ReqBody删除后,文件就能注册成功了。麻烦帮忙看下,是 pb 文件本身的问题,还是解析的问题?多谢。
错误信息: