golua

package module
v0.0.0-...-1b6d10a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 10, 2026 License: Apache-2.0 Imports: 2 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewValue

func NewValue(l *lua.State) structlua.Value

NewValue wraps the Lua value at the top of the stack (index -1) as a structlua.Value.

Example
package main

import (
	"fmt"
	"log"

	"github.com/Shopify/go-lua"
	"github.com/tomgray/structlua"
	"github.com/tomgray/structlua/golua"
)

func main() {
	type ServerConfig struct {
		Host    string   `lua:"host"`
		Port    int      `lua:"port"`
		TLS     bool     `lua:"tls"`
		Allowed []string `lua:"allowed_hosts"`
	}

	l := lua.NewState()
	lua.OpenLibraries(l)

	script := `
		return {
			host = "0.0.0.0",
			port = 8080,
			tls = true,
			allowed_hosts = { "example.com", "api.example.com" },
		}
	`
	if err := lua.DoString(l, script); err != nil {
		log.Fatal(err)
	}

	var cfg ServerConfig
	if err := structlua.Unmarshal(golua.NewValue(l), &cfg); err != nil {
		log.Fatal(err)
	}

	fmt.Printf("%+v\n", cfg)
}
Output:
{Host:0.0.0.0 Port:8080 TLS:true Allowed:[example.com api.example.com]}

func NewValueAt

func NewValueAt(l *lua.State, idx int) structlua.Value

NewValueAt wraps the Lua value at the given stack index as a structlua.Value.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL