(function()
print(1)
if true then
return
end
print(2)
end)()
function f()
a = 1
function f1()
print(a)
end
f1()
end
f()
-- require 其他的模块
-- local ngx_lua 相关的 api
-- local lua 相关的函数(再把 lua 相关的独立出来)
local utils = require "modules.utils"
local metadata = require "modules.metadata"
local cjson = require "cjson.safe"
local get_method = ngx.req.get_method
local get_uri_args = ngx.req.get_uri_args
local null = utils.null
local str_gsub = string.gsub
<if-statement> and <true_result> or <false_result>
lua_xxx
主要是 lua 基本 APIluaL
是封装过的基本 API{
"cmd": ["/usr/local/bin/lua", "$file"],
"file_regex": "^(...*?):([0-9]*):?([0-9]*)",
"selector": "source.lua"
}
只能用于build, 不能传参数, 相当于lua [filename.lua].
brew install lua luajit metalua luarocks
luarocks install luasocket