lua 安装luarocks 并且获取唯一id

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/zhengwish/article/details/88668751

1、已安装lua 5.1.4

2、安装luarocks

wget https://luarocks.github.io/luarocks/releases/luarocks-3.0.4.tar.gz
tar -zxvf luarocks-3.0.4.tar.gz
cd luarocks-3.0.4/
./configure
make
make install
make bootstrap

3、安装snowflake

luarocks install snowflake

4、编写lua脚本

local sf = require "snowflake"
sf.init(0x01, 0x01)
local snowflakeId = sf.next_id()
print(snowflakeId)

5、执行脚本 后提示说snowflake找不到

将snowflake.so文件拷贝到提示中指定的位置,比如我的是在 /usr/lib64/lua/5.1目录下

6、重新执行,将成功打印唯一id

其中lua的snowflake地址:https://github.com/stuartcarnie/lua-snowflake

猜你喜欢

转载自blog.csdn.net/zhengwish/article/details/88668751