feat: add goro function

this function will run another function, but in a goroutine
!!
pull/59/head
sammyette 2021-05-25 20:44:03 -04:00
parent 9defa737f4
commit c1b9e5bc81
No known key found for this signature in database
GPG Key ID: 50EE40A2809851F5
1 changed files with 6 additions and 0 deletions

6
lua.go
View File

@ -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()
}