mirror of
https://github.com/akyaiy/GoSally-mvp.git
synced 2026-01-05 12:32:25 +00:00
Refactor error handling and utility functions; remove deprecated code and improve logging
This commit is contained in:
26
core/utils/internal_lua.go
Normal file
26
core/utils/internal_lua.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package utils
|
||||
|
||||
import lua "github.com/yuin/gopher-lua"
|
||||
|
||||
func ConvertLuaTypesToGolang(value lua.LValue) any {
|
||||
switch value.Type() {
|
||||
case lua.LTString:
|
||||
return value.String()
|
||||
case lua.LTNumber:
|
||||
return float64(value.(lua.LNumber))
|
||||
case lua.LTBool:
|
||||
return bool(value.(lua.LBool))
|
||||
case lua.LTTable:
|
||||
result := make(map[string]interface{})
|
||||
if tbl, ok := value.(*lua.LTable); ok {
|
||||
tbl.ForEach(func(key lua.LValue, value lua.LValue) {
|
||||
result[key.String()] = ConvertLuaTypesToGolang(value)
|
||||
})
|
||||
}
|
||||
return result
|
||||
case lua.LTNil:
|
||||
return nil
|
||||
default:
|
||||
return value.String()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user