MCPcopy Create free account
hub / github.com/cel-expr/cel-go / Globals

Function Globals

cel/options.go:500–512  ·  view source on GitHub ↗

Globals sets the global variable values for a given program. These values may be shadowed by variables with the same name provided to the Eval() call. If Globals is used in a Library with a Lib EnvOption, vars may shadow variables provided by previously added libraries. The vars value may either be

(vars any)

Source from the content-addressed store, hash-verified

498//
499// The vars value may either be an `cel.Activation` instance or a `map[string]any`.
500func Globals(vars any) ProgramOption {
501 return func(p *prog) (*prog, error) {
502 defaultVars, err := NewActivation(vars)
503 if err != nil {
504 return nil, err
505 }
506 if p.defaultVars != nil {
507 defaultVars = interpreter.NewHierarchicalActivation(p.defaultVars, defaultVars)
508 }
509 p.defaultVars = defaultVars
510 return p, nil
511 }
512}
513
514// OptimizeRegex provides a way to replace the InterpretableCall for regex functions. This can be used
515// to compile regex string constants at program creation time and report any errors and then use the

Callers 1

TestGlobalVarsFunction · 0.85

Calls 2

NewActivationFunction · 0.70

Tested by 1

TestGlobalVarsFunction · 0.68