<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
  <channel>
    <title>lua - 分类 - cfanzp学习笔记</title>
    <link>https://cfanzp008.github.io/categories/lua/</link>
    <description>lua - 分类 - cfanzp学习笔记</description>
    <generator>Hugo -- gohugo.io</generator><language>zh-CN</language><managingEditor>cfan.zp@qq.com (cfanzp)</managingEditor>
      <webMaster>cfan.zp@qq.com (cfanzp)</webMaster><lastBuildDate>Sat, 01 Apr 2023 16:41:57 &#43;0800</lastBuildDate><atom:link href="https://cfanzp008.github.io/categories/lua/" rel="self" type="application/rss+xml" /><item>
  <title>lua常见问题</title>
  <link>https://cfanzp008.github.io/lua-question/</link>
  <pubDate>Sat, 01 Apr 2023 16:41:57 &#43;0800</pubDate>
  <author>作者</author>
  <guid>https://cfanzp008.github.io/lua-question/</guid>
  <description><![CDATA[]]></description>
</item>
<item>
  <title>lua中给日志关键字加上颜色</title>
  <link>https://cfanzp008.github.io/terminal-color/</link>
  <pubDate>Tue, 06 Sep 2022 17:05:35 &#43;0800</pubDate>
  <author>作者</author>
  <guid>https://cfanzp008.github.io/terminal-color/</guid>
  <description><![CDATA[]]></description>
</item>
<item>
  <title>lua中如何实现打印行号和当前函数名？</title>
  <link>https://cfanzp008.github.io/lua-debug/</link>
  <pubDate>Tue, 23 Aug 2022 11:28:13 &#43;0800</pubDate>
  <author>作者</author>
  <guid>https://cfanzp008.github.io/lua-debug/</guid>
  <description><![CDATA[lua中如何实现打印行号和当前函数名？ lua中可以使用debug的get_info方法来获取当前的堆栈信息，进而可以打印出相关的环境信息，具体信息包括:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 table: 0x7f92b8f19e80 { isvararg = false , what = Lua , func = function: 0x7f92b7b8d600 , namewhat = , istailcall = true , lastlinedefined = 16 , source = @service/db/db_interactionemotion.lua , linedefined = 7 , currentline = 11 , ntransfer = 0 , short_src = service/db/db_interactionemotion.lua , ftransfer = 0 , nups = 3 , nparams = 0 , } lua中需要打印行号多半是日志需求，下面是一个demo:]]></description>
</item>
<item>
  <title>lua中的self</title>
  <link>https://cfanzp008.github.io/lua-self/</link>
  <pubDate>Tue, 09 Aug 2022 22:40:06 &#43;0800</pubDate>
  <author>作者</author>
  <guid>https://cfanzp008.github.io/lua-self/</guid>
  <description><![CDATA[lua中的self self的用法 使用:定义的函数默认接收第一个参数是self 使用:调用函数默认传入第一个参数是调用者 使用.定义和调用函数不会接受或传入self :为我们省下了一个参数，下面例子中的A:Add()与A.Add(t)是等价的
1 2 3 4 5 6 7 local A = {x = 1, y = 2} function t:Add() return (self.x + self.y) end print(A:Add()) print(A.Add(A)) ]]></description>
</item>
<item>
  <title>lua面向对象编程</title>
  <link>https://cfanzp008.github.io/lua-new/</link>
  <pubDate>Mon, 08 Aug 2022 09:18:02 &#43;0800</pubDate>
  <author>作者</author>
  <guid>https://cfanzp008.github.io/lua-new/</guid>
  <description><![CDATA[lua面向对象编程 对象定义: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 local logger = require &#34;common.]]></description>
</item>
<item>
  <title>lua第三方开源库学习整理</title>
  <link>https://cfanzp008.github.io/lua-3rd/</link>
  <pubDate>Wed, 03 Aug 2022 09:01:02 &#43;0800</pubDate>
  <author>cfanzp</author>
  <guid>https://cfanzp008.github.io/lua-3rd/</guid>
  <description><![CDATA[lua第三方开源库学习整理 skynet框架:https://github.com/cloudwu/skynet lua的protobuf工具-pbc:https://github.com/cloudwu/pbc lua-cjson库:https://github.com/mpx/lua-cjson 一个lua写的websocket库https://github.com/flaribbit/love2d-lua-websocket lua-protobuf库https://github.com/starwing/lua-protobuf/blob/master/README.zh.md ]]></description>
</item>
<item>
  <title>lua中string.pack,string.unpack的用法</title>
  <link>https://cfanzp008.github.io/lua-string-pack/</link>
  <pubDate>Wed, 03 Aug 2022 08:34:18 &#43;0800</pubDate>
  <author>cfanzp</author>
  <guid>https://cfanzp008.github.io/lua-string-pack/</guid>
  <description><![CDATA[lua中string.pack,string.unpack的用法 lua string.pack的用法,查看lua5.4的官方帮助手册不难找到下面的解释:
string.pack (fmt, v1, v2, ···)
Returns a binary string containing the values v1, v2, etc. serialized in binary form (packed) according to the format string fmt (see §6.4.2).
最近一个新项目要将brotobuf协议包裹在http协议内进行传输，刚好用到了这个函数,在pb数据包封包后，协议按3部分拼接:
1 数据包长度(msgid + pb_data) + 协议ID + pb数据包体 封包过程如下:
1 2 3 local pb_data = pb_helper.pb_encode(msgname, msg) local buf = string.pack(&#34;&gt;I4c&#34; .. #pb_data, msgid, pb_data) local send_buf = string.pack(&#34;&gt;s2&#34;, buf) 解包过程如下:
1 2 3 local buf = msg --des_decode(secret, msg) local len = string.]]></description>
</item>
<item>
  <title>lua-luacheck</title>
  <link>https://cfanzp008.github.io/lua-luacheck/</link>
  <pubDate>Mon, 01 Aug 2022 18:16:43 &#43;0800</pubDate>
  <author>cfanzp</author>
  <guid>https://cfanzp008.github.io/lua-luacheck/</guid>
  <description><![CDATA[luacheck luacheck 是一个lua代码的静态检查工具，可以用来发现lua代码中的一些缺陷，规范lua代码的书写。lua是一们解释型语言，很多错误只有在运行时才会暴露出来。借助静态检查工具能够方便我们在前期就发现一些低级错误并及时修正。
安装 ubuntu 1 sudo apt install lua-check centos 1 yum install luarocks 这里使用luarocks来安装luacheck,安装过程中可能遇到报错的问题。
安装报错信息: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 root@mybonline1 mybonline]# luarocks install luacheck Installing https://luarocks.org/luacheck-0.25.0-1.src.rock... Using https://luarocks.org/luacheck-0.25.0-1.src.rock... switching to &#39;build&#39; mode Missing dependencies for luacheck: luafilesystem &gt;= 1.6.3 argparse &gt;= 0.6.0 Using https://luarocks.org/luafilesystem-1.8.0-1.src.rock... switching to &#39;build&#39; mode gcc -O2 -fPIC -I/usr/include -c src/lfs.c -o src/lfs.o src/lfs.]]></description>
</item>
<item>
  <title>Lua开发手册</title>
  <link>https://cfanzp008.github.io/lua-man/</link>
  <pubDate>Sun, 31 Jul 2022 09:47:48 &#43;0800</pubDate>
  <author>cfanzp</author>
  <guid>https://cfanzp008.github.io/lua-man/</guid>
  <description><![CDATA[lua5.3开发手册 https://cloud.tencent.com/developer/doc/1141 云风翻译:http://cloudwu.github.io/lua53doc/manual.html lua5.4开发手册 官网英文版:http://www.lua.org/manual/5.4/manual.html lua匹配库Lpeg 官网: http://www.inf.puc-rio.br/~roberto/lpeg/ 帮助: https://www.jianshu.com/p/e8e1c5abfdbb tutorial: https://lua-users.org/wiki/LpegTutorial luasocket github: https://github.com/lunarmodules/luasocket 使用demo: https://blog.csdn.net/h1023417614/article/details/52297408 lua md5 github: https://github.com/keplerproject/md5 jemalloc http://jemalloc.net/ ]]></description>
</item>
</channel>
</rss>
