goval: github.com/maja42/goval Index | Files | Directories

package goval

import "github.com/maja42/goval"

Index

Package Files

evaluator.go

type Evaluator Uses

type Evaluator struct {
}

Evaluator is used to evaluate expression strings.

func NewEvaluator Uses

func NewEvaluator() *Evaluator

NewEvaluator creates a new evaluator.

func (*Evaluator) Evaluate Uses

func (e *Evaluator) Evaluate(str string, variables map[string]interface{}, functions map[string]ExpressionFunction) (result interface{}, err error)

Evaluate the given expression string.

Optionally accepts a list of variables (accessible but not modifiable from within expressions).

Optionally accepts a list of expression functions (can be called from within expressions).

Returns the resulting object or an error.

Stateless. Can be called concurrently. If expression functions modify variables, concurrent execution requires additional synchronization.

type ExpressionFunction Uses

type ExpressionFunction = func(args ...interface{}) (interface{}, error)

ExpressionFunction can be called from within expressions.

The returned object needs to have one of the following types: `nil`, `bool`, `int`, `float64`, `[]interface{}` or `map[string]interface{}`.

Directories

PathSynopsis
example
internal

Package goval imports 1 packages (graph) and is imported by 1 packages. Updated 2018-08-01. Refresh now. Tools for package owners.