[WIP] Initial commit
This commit is contained in:
34
cmd/02-TestLuaScript/main.go
Normal file
34
cmd/02-TestLuaScript/main.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"doll/internal/log"
|
||||
"os"
|
||||
|
||||
lua "github.com/yuin/gopher-lua"
|
||||
)
|
||||
|
||||
func main() {
|
||||
log.Init("info", os.Stderr)
|
||||
|
||||
L := lua.NewState()
|
||||
defer L.Close()
|
||||
|
||||
// Load the Lua script file.
|
||||
log.Info("Loading ./test_data/01-test.lua")
|
||||
|
||||
luaCode, err := os.ReadFile("./test_data/01-test.lua")
|
||||
|
||||
if err != nil {
|
||||
log.Errorf("Error reading Lua file: %s", err)
|
||||
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if err := L.DoString(string(luaCode)); err != nil {
|
||||
log.Errorf("Error evaluating Lua code: %s", err)
|
||||
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
/* vim: set ft=go noet ai ts=4 sw=4 sts=4: */
|
||||
Reference in New Issue
Block a user