cetnos7下openresty使用luarocks 进行lua的包管理

先安装一下包管理工具

yum install luarocks lua-devel -y

luarocks install lpack

ln -s /usr/lib64/lua /usr/local/lib

指定luarocks安装路径参数备忘

luarocks install lpack --tree=/usr/local/lib64

测试一下包安装有没有问题

 /usr/local/openresty/bin/resty -e "require 'pack'"

我想是没有问题了,,顺便测试一下pack

 

require"pack"

bpack=string.pack
bunpack=string.unpack

function hex(s)
 s=string.gsub(s,"(.)",function (x) return string.format("%02X",string.byte(x)) end)
 return s
end

a=bpack("Ab8","\027Lua",5*16+1,0,1,4,4,4,8,0)
--print(hex(a),string.len(a))

b=string.dump(hex)
b=string.sub(b,1,string.len(a))
print(a==b,string.len(b))
print(bunpack(b,"bA3b8"))

i=314159265 f="<I>I=I"
a=bpack(f,i,i,i)
--print(hex(a))
print(bunpack(a,f))

i=3.14159265 f="<d>d=d"
a=bpack(f,i,i,i)
--print(hex(a))
print(bunpack(a,f))

 

posted @ 2018-03-16 14:42 冷侃 阅读(...) 评论(...) 编辑 收藏