-
Notifications
You must be signed in to change notification settings - Fork 685
Open
Description
- What version of GopherLua are you using?
- What version of Go are you using? :
go version go1.21.4 darwin/amd64
- What operating system and processor architecture are you using?
Mac OS Catalina 10.15.3 x86_64
- What did you do?
i do this: (go) L.DoFile -> (lua)xpcall -> (lua)dofile
here the code
golang:
L := lua.NewState()
defer L.Close()
if err := L.DoFile("init.lua"); err != nil {
fmt.Println(err.Error())
}
init.lua
xpcall(dofile, printErr, "first.lua") -- not work
first.lua
print("sth.")
- What did you expect to see?
:L.DoFile should return,and first.lua should run
- What did you see instead?
:go stuck there, only happens when xpcall -> dofile
➜ goluadofile ls
first.lua init.lua run.go
➜ goluadofile go run ./run.go
start go run
[init] start
run_path: init
^Csignal: interrupt
always stuck until ^C to interrupt it.
- here are all source code files:
run.go
package main
import (
"fmt"
lua "github.com/yuin/gopher-lua"
)
func main() {
fmt.Println("start go run")
L := lua.NewState()
defer L.Close()
if err := L.DoFile("init.lua"); err != nil {
fmt.Println(err.Error())
}
fmt.Println("end go run")
}
init.lua
local function printErr(err)
print(err)
print(debug.traceback())
end
local function test( ... )
print("is test function run, args: ", ...)
end
run_path = "init"
print("[init] start")
print("run_path:", run_path)
-- xpcall(test, printErr, "test") -- work fine
-- dofile("first.lua") -- work fine
-- pcall(dofile, "first.lua") -- work fine
xpcall(dofile, printErr, "first.lua") -- not work
print("run_path:", run_path)
print("[init] end")
first.lua
print("[first] start")
run_path = "first"
print("[first] end")
- I don’t know if I set lua.NewState() up wrong, never mind to give more information
Metadata
Metadata
Assignees
Labels
No labels