expression

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2024 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ExpressionFunctions = map[string]govaluate.ExpressionFunction{
	"strlen": func(args ...interface{}) (interface{}, error) {
		length := len(args[0].(string))
		return (float64)(length), nil
	},
	"sFromObj": FromObject,
	"nFromObj": NumberFromObject,
}
View Source
var FromObject = func(args ...interface{}) (interface{}, error) {
	dataMap, ok := args[0].(map[string]interface{})
	if !ok {
		return nil, errors.New("not a object")
	}
	key, ok := args[1].(string)
	if !ok {
		return nil, errors.New("have key get")
	}
	queryData := daq.NewDaq(dataMap)
	res, err := queryData.Query(key)
	if err != nil {
		return nil, err
	}
	return res.Interface()
}
View Source
var NumberFromObject = func(args ...interface{}) (interface{}, error) {
	dataMap, ok := args[0].(map[string]interface{})
	if !ok {
		return nil, errors.New("not a object")
	}
	key, ok := args[1].(string)
	if !ok {
		return nil, errors.New("have key get")
	}
	queryData := daq.NewDaq(dataMap)
	res, err := queryData.Query(key)
	if err != nil {
		return nil, err
	}
	return res.Number()
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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