stdlib

package
v1.5.5 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2026 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GlobalVarsFrom

func GlobalVarsFrom(ctx context.Context) map[string]any

GlobalVarsFrom extracts global variables from a context. Returns nil if not set.

func RegisterAll

func RegisterAll(builtins map[string]*executor.BuiltinFunc)

RegisterAll registers all standard library functions into the builtins map.

Prefer Shared unless you need a table you own and intend to modify.

func Shared added in v1.5.3

func Shared() map[string]*executor.BuiltinFunc

Shared returns the standard library's builtin table, built once per process and reused by every registry.

Building it costs ~22us and several hundred allocations, and a registry that rebuilt it paid that on construction. Nothing about a BuiltinFunc is per-registry — they close over no registry state — so there is no reason for each one to own a copy. A host that creates a registry per tenant or per request was paying this repeatedly for an identical result.

The returned map MUST NOT be mutated: it is shared by every registry in the process, and a write here would be visible to all of them (and would race with concurrent lookups). Registry keeps host-registered builtins in a separate overlay for exactly this reason — see Registry.RegisterBuiltin.

func WithGlobalVars

func WithGlobalVars(ctx context.Context, globals map[string]any) context.Context

WithGlobalVars attaches pre-built global variables to a context.

Types

This section is empty.

Jump to

Keyboard shortcuts

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