Categorygithub.com/greedyor/glua
modulepackage
0.0.19
Repository: https://github.com/greedyor/glua.git
Documentation: pkg.go.dev

# README

glua

Relying on the gopher-lua plugin to quickly process lua.

usage

Import a package.

import (
    "github.com/greedyor/glua"
)

Run scripts

data, err := glua.ExecToPath("./xxapi.lua")
if err != nil {
	panic("ExecToPath error:", err)
}

or

data, err := glua.ExecToCode("print("hello")")
if err != nil {
	panic("ExecToCode error:", err)
}

xxapi.lua example

-- require func
local http = require("http")
local json = require("json")
local result = require("result")
-- request url
local response, err = http.request("https://github.com/manifest.json", "GET")
if err ~= nil then
    result.errors(err)
else
    -- json string to table type
    local tableData = json.decodeToTable(response)

    -- fieids set
    local fields = {
        name = tableData.name,
        shortName = tableData.short_name,
        icons = tableData.icons,
    }

    result.success(json.encodeToTable(fields))
end

Installation

go get github.com/greedyor/glua

GopherLua supports >= Go1.9.

# Functions

create new a struct and load lua script.
No description provided by the author
No description provided by the author
No description provided by the author
import packages.
init base packages.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Variables

No description provided by the author
No description provided by the author
Temporarily set up some Lua methods...
No description provided by the author
No description provided by the author

# Structs

No description provided by the author
No description provided by the author