Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
14009697f0 | |||
f47d36eb8b |
2
DOCS.md
2
DOCS.md
@ -109,7 +109,7 @@ if err != nil {
|
|||||||
```
|
```
|
||||||
|
|
||||||
### ToTable(index int) (any, error)
|
### ToTable(index int) (any, error)
|
||||||
Converts a Lua table to optimal Go type ([]int, []string, map[string]any, etc.).
|
Converts a Lua table to optimal Go type; arrays or `map[string]any`.
|
||||||
```go
|
```go
|
||||||
table, err := L.ToTable(-1)
|
table, err := L.ToTable(-1)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -116,7 +116,7 @@ L.PushValue(stuff) // Handles all Go types automatically
|
|||||||
|
|
||||||
// Lua → Go with automatic type detection
|
// Lua → Go with automatic type detection
|
||||||
L.GetGlobal("some_table")
|
L.GetGlobal("some_table")
|
||||||
result, err := L.ToTable(-1) // Returns optimal Go type ([]int, map[string]string, etc.)
|
result, err := L.ToTable(-1) // Returns optimal Go type (typed array, or map[string]any)
|
||||||
```
|
```
|
||||||
|
|
||||||
### Table Builder
|
### Table Builder
|
||||||
|
@ -206,6 +206,8 @@ func (s *State) PushValue(v any) error {
|
|||||||
s.PushNumber(val)
|
s.PushNumber(val)
|
||||||
case string:
|
case string:
|
||||||
s.PushString(val)
|
s.PushString(val)
|
||||||
|
case []byte:
|
||||||
|
s.PushString(string(val))
|
||||||
case []int:
|
case []int:
|
||||||
return s.pushIntSlice(val)
|
return s.pushIntSlice(val)
|
||||||
case []string:
|
case []string:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user