2 Star 0 Fork 0

小蚂蚁 / gurl

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
luabind_main.go 1007 Bytes
一键复制 编辑 原始数据 按行查看 历史
package conn
import (
"github.com/guonaihong/glua/lib/cmdparse"
"github.com/guonaihong/glua/lib/json"
"github.com/guonaihong/glua/lib/log"
"github.com/guonaihong/glua/lib/socket"
"github.com/guonaihong/glua/lib/strings"
"github.com/guonaihong/glua/lib/time"
"github.com/guonaihong/glua/lib/uuid"
"github.com/yuin/gopher-lua"
)
type LuaEngine struct {
L *lua.LState
args string
}
func (l *LuaEngine) getCmdArgs(L *lua.LState) int {
l.L.Push(lua.LString(l.args)) /* push result */
return 1
}
func NewLuaEngine(kargs string) *LuaEngine {
L := lua.NewState()
engine := &LuaEngine{L: L, args: kargs}
L.PreloadModule("socket", socket.Loader)
L.PreloadModule("flag", cmdparse.Loader)
L.PreloadModule("time", time.Loader)
L.PreloadModule("strings", strings.Loader)
L.PreloadModule("log", log.Loader)
L.PreloadModule("uuid", uuid.Loader)
L.PreloadModule("json", json.Loader)
L.SetGlobal("get_cmd_args", L.NewFunction(engine.getCmdArgs))
//socket.RegisterSocketType(L)
return engine
}
Go
1
https://gitee.com/guonaihong/gurl.git
git@gitee.com:guonaihong/gurl.git
guonaihong
gurl
gurl
v0.0.1

搜索帮助