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

match

package
v0.42.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const ID = "match"

Variables

This section is empty.

Functions

func Bundle

func Bundle(_ map[string]string) compiler.Bundle

func CompileCondition added in v0.16.0

func CompileCondition(source string) (*vm.Program, error)

CompileCondition compiles an expression using Flow's input-dot syntax.

func EvaluateProgram added in v0.16.0

func EvaluateProgram(program *vm.Program, env map[string]any) (any, error)

EvaluateProgram runs a compiled condition or subject expression.

func FirstMatchingCase added in v0.16.0

func FirstMatchingCase(cases []ConditionCase, env map[string]any) int

FirstMatchingCase returns the first condition that evaluates to true, or the first default case reached in order. Evaluation failures are skipped, matching the existing match and @on_error behavior.

func KindEnvironment added in v0.16.0

func KindEnvironment() map[string]any

KindEnvironment returns fresh bindings for symbolic Kernel kinds.

func KindEnvironmentFor added in v0.16.0

func KindEnvironmentFor(kindValue any) map[string]any

KindEnvironmentFor returns symbolic bindings with the same runtime representation as kindValue. Legacy @on_error exposes error.kind as a string; expression guards expose it as xerr.Kind.

func KindSymbol added in v0.16.0

func KindSymbol(kind xerr.Kind) string

KindSymbol returns the source spelling of a built-in Kernel kind.

func ResolveKindSymbol added in v0.16.0

func ResolveKindSymbol(symbol string) (xerr.Kind, bool)

ResolveKindSymbol maps a symbolic Flow name to one of the built-in Kernel kinds. It intentionally does not treat xerr.Kind as a closed runtime set: custom values remain possible and are handled by explicit else cases.

func WithKindEnvironment deprecated added in v0.16.0

func WithKindEnvironment(env map[string]any) map[string]any

WithKindEnvironment is retained for backward compatibility with callers that predate the file-local symbol path.

Deprecated: use WithSymbolEnvironment(ctx, env).

func WithSymbolEnvironment added in v0.25.0

func WithSymbolEnvironment(ctx context.Context, env map[string]any) map[string]any

WithSymbolEnvironment returns a fresh expression environment with every registered symbol namespace bound: process-global namespaces from compiler.RegisterNamespace, then any file-local namespace installed on ctx by the compiler after @symbols preprocessing, then xerr in the string-or-typed form the current error source expects. Caller-supplied keys win on collision.

Types

type Case

type Case struct {
	Condition string
	IsDefault bool
	Body      compiler.Expr
}

type ConditionCase added in v0.16.0

type ConditionCase struct {
	Program   *vm.Program
	IsDefault bool
}

ConditionCase is one ordered expression condition, or a default branch. A nil Program is skipped unless IsDefault is true.

type Expr

type Expr struct {
	Subject string
	Cases   []Case
}

func (*Expr) Analyze

func (m *Expr) Analyze(resolver compiler.CapabilityResolver) error

func (*Expr) Build

func (m *Expr) Build(ctx context.Context, bCtx *compiler.BuildContext) (action.AnyAction, error)

func (*Expr) Children

func (m *Expr) Children() []compiler.Expr

func (*Expr) DescribeActionGraph added in v0.23.0

func (m *Expr) DescribeActionGraph() compiler.ActionGraphDescription

func (*Expr) Node

func (*Expr) Node()

Jump to

Keyboard shortcuts

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