Help us shape the future of Go! Take the 2026 Go Developer Survey

lua

package
v0.12.3 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager coordinates multiple sandboxed Lua states.

func NewManager

func NewManager(logger *log.Loggee) *Manager

NewManager creates a manager with an optional logger. When logger is nil, scripting logs are dropped.

func (*Manager) Close

func (m *Manager) Close()

Close stops all persistent instances managed by this manager.

func (*Manager) CreatePersistent added in v0.12.2

func (m *Manager) CreatePersistent(code string, opts Options) (string, error)

CreatePersistent compiles the provided script once and returns an ID that can be rerun later.

func (*Manager) DestroyPersistent added in v0.12.2

func (m *Manager) DestroyPersistent(id string)

DestroyPersistent removes the persistent VM identified by id.

func (*Manager) RegisterFunction

func (m *Manager) RegisterFunction(name string, fn lua.LGFunction)

RegisterFunction exposes a Go function to all future Lua states managed by this manager.

func (*Manager) RunPersistent added in v0.12.2

func (m *Manager) RunPersistent(id string) error

RunPersistent executes the persistent VM associated with id.

func (*Manager) RunVolatile added in v0.12.2

func (m *Manager) RunVolatile(code string, opts Options) error

RunVolatile creates a temporary VM, executes the script, and destroys it afterwards.

func (*Manager) SetDefaultSender

func (m *Manager) SetDefaultSender(sender string)

SetDefaultSender overrides the sender name used when logging from scripts.

type Options added in v0.12.2

type Options struct {
	Name      string
	Functions map[string]lua.LGFunction
	Globals   map[string]lua.LValue
	Mode      VMMode
}

Options configure a Lua VM creation.

type VMMode added in v0.12.2

type VMMode uint8
const (
	Sandboxed VMMode = iota
	Elevated
	Unsafe
)

Source Files

  • manager.go

Jump to

Keyboard shortcuts

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