1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-29 23:51:29 +00:00
Beego/vendor/github.com/Knetic/govaluate/parameters.go

33 lines
714 B
Go
Raw Normal View History

2018-11-09 04:37:28 +00:00
package govaluate
import (
"errors"
)
/*
Parameters is a collection of named parameters that can be used by an EvaluableExpression to retrieve parameters
when an expression tries to use them.
*/
type Parameters interface {
/*
Get gets the parameter of the given name, or an error if the parameter is unavailable.
Failure to find the given parameter should be indicated by returning an error.
*/
Get(name string) (interface{}, error)
}
type MapParameters map[string]interface{}
func (p MapParameters) Get(name string) (interface{}, error) {
value, found := p[name]
if !found {
errorMessage := "No parameter '" + name + "' found."
return nil, errors.New(errorMessage)
}
return value, nil
}