From c1b9e5bc818a80eed7272a1bb94c43284b898729 Mon Sep 17 00:00:00 2001 From: sammyette <38820196+TorchedSammy@users.noreply.github.com> Date: Tue, 25 May 2021 20:44:03 -0400 Subject: [PATCH] feat: add goro function this function will run another function, but in a goroutine !! --- lua.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lua.go b/lua.go index 2fb1ef4..110746a 100644 --- a/lua.go +++ b/lua.go @@ -12,6 +12,7 @@ import ( "hilbish/golibs/fs" "github.com/yuin/gopher-lua" + "layeh.com/gopher-luar" ) var minimalconf = ` @@ -30,6 +31,7 @@ func LuaInit() { l.SetGlobal("alias", l.NewFunction(hshalias)) l.SetGlobal("appendPath", l.NewFunction(hshappendPath)) l.SetGlobal("exec", l.NewFunction(hshexec)) + l.SetGlobal("goro", luar.New(l, hshgoroutine)) // yes this is stupid, i know l.PreloadModule("hilbish", HilbishLoader) @@ -151,3 +153,7 @@ func hshexec(L *lua.LState) int { syscall.Exec(cmdPath, cmdArgs, os.Environ()) return 0 // random thought: does this ever return? } + +func hshgoroutine(gofunc func()) { + go gofunc() +}