Documentation
¶
Index ¶
Constants ¶
View Source
const ( DefaultInstructionLimit = 1_000_000 DefaultMemoryLimit = 16 * 1024 * 1024 DefaultTimeout = 5 * time.Second )
Variables ¶
View Source
var ( ErrInstructionLimit = errors.New("lua: instruction limit exceeded") ErrMemoryLimit = errors.New("lua: memory limit exceeded") ErrTimeout = errors.New("lua: execution timeout") ErrUnsafeOperation = errors.New("lua: unsafe operation blocked") )
View Source
var BuiltInTemplates = []LuaFilterTemplate{
{
Name: "uppercase",
Script: `return string.upper(input)`,
},
{
Name: "lowercase",
Script: `return string.lower(input)`,
},
{
Name: "reverse",
Script: `return string.reverse(input)`,
},
{
Name: "trim_lines",
Script: `local lines = {} for line in input:gmatch("[^\n]+") do table.insert(lines, line:gsub("^%s*(.-)%s*$", "%1")) end return table.concat(lines, "\n")`,
},
{
Name: "remove_empty",
Script: `local lines = {} for line in input:gmatch("[^\n]+") do if line:gsub("%s", "") ~= "" then table.insert(lines, line) end end return table.concat(lines, "\n")`,
},
}
Functions ¶
This section is empty.
Types ¶
type LuaFilterTemplate ¶
func GetTemplate ¶
func GetTemplate(name string) *LuaFilterTemplate
type LuaSandbox ¶
type LuaSandbox struct {
// contains filtered or unexported fields
}
func NewLuaSandbox ¶
func NewLuaSandbox() *LuaSandbox
Click to show internal directories.
Click to hide internal directories.