script

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: May 11, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package script defines a language-agnostic script execution interface. Implementations (e.g. script/jsrt for JavaScript, script/luart for Lua via gopher-lua) provide concrete runtimes that satisfy the Runtime interface. Host APIs for Env are built with script/bindings; see bindings/doc.go for layout and conventions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Env

type Env struct {
	// Config is script-level configuration, accessible as a global in the script.
	Config map[string]any

	// Bindings maps names to host objects injected into the script's global scope.
	// Each value is typically a map[string]any of Go functions callable from the script.
	Bindings map[string]any
}

Env carries per-execution configuration and host bindings.

type Runtime

type Runtime interface {
	Exec(ctx context.Context, name, source string, env *Env) (*Signal, error)
}

Runtime executes scripts with injected host bindings. Implementations must be safe for concurrent use.

type Signal

type Signal struct {
	Type    string `json:"type"`
	Message string `json:"message,omitempty"`
}

Signal represents a control signal from a script back to the host.

Directories

Path Synopsis
Package bindings assembles host capabilities into a script.Env for any script.Runtime implementation (jsrt, luart, etc.).
Package bindings assembles host capabilities into a script.Env for any script.Runtime implementation (jsrt, luart, etc.).
Package jsrt provides a goja-based JavaScript implementation of script.Runtime.
Package jsrt provides a goja-based JavaScript implementation of script.Runtime.
Package luart provides a pure-Go Lua 5.1 implementation of script.Runtime using github.com/yuin/gopher-lua (no CGO).
Package luart provides a pure-Go Lua 5.1 implementation of script.Runtime using github.com/yuin/gopher-lua (no CGO).

Jump to

Keyboard shortcuts

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