pbc
pbc copied to clipboard
protobuf.lua:217: attempt to call local 'func'
I am using this lua binding module https://raw.githubusercontent.com/cloudwu/pbc/master/binding/lua53/protobuf.lua
but when I want to encode someting like this, it will show an error below
protobuf.lua:217: attempt to call local 'func'
proto 文件
package lm;
message test
{
required int32 uid = 1;
required int32 param = 2;
optional string param1 = 3;
repeated string param2 = 4;
};
local pbtt = require "lib.protobuf"
local pb_file_chat = "/proto/test.pb"
pbtt.register_file (pb_file_chat)
local pb1_decode = pbtt.decode
local pb1_encode = pbtt.encode
local data = { uid =1}
local pbf ,err = pb1_encode('lm.test',data)
print( type(pbf)) -- nil
It's ok here .
local data = { uid =1}
local pbf ,err = pb1_encode('lm.test',data)
local dc = pb1_decode('lm.test', pbf)
print( type(pbf)) -- string
print(dc.uid) -- 1