1
0
mirror of https://github.com/astaxie/beego.git synced 2024-12-24 02:30:49 +00:00
Beego/vendor/github.com/Knetic/govaluate/parameters.go

33 lines
714 B
Go
Raw Normal View History

2018-07-30 04:05:51 +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
}