Move examples to examples dir, now LoadJsonFile() also returns err

* Move examples from cmd to examples dir
* Update Makefile
* LoadJsonFile() dies in-place on read or parse error which is not correct
* LoadJsonFile() wastes Instance map, now it returns its own map and error if any
This commit is contained in:
eleksir
2025-10-27 20:28:27 +03:00
parent 521ac9abc0
commit f2948d705a
9 changed files with 102 additions and 86 deletions

View File

@@ -1,21 +0,0 @@
package main
import (
"doll/internal/doll"
"doll/internal/log"
"os"
"github.com/davecgh/go-spew/spew"
)
func main() {
log.Init("info", os.Stderr)
log.Info("loading config.json")
data := doll.LoadJsonFile("test_data/config.json")
log.Info("data fron config.json is")
spew.Dump(data)
}
/* vim: set ft=go noet ai ts=4 sw=4 sts=4: */

View File

@@ -1,34 +0,0 @@
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: */