// RegFunction is Top level function// the same function name only needs to be registered once.// double is register function name.// 1 is a number of parameter signatures. should be -1, 0, or a positive integer// func(expr ...engine.ExprAST) float64 is your function.
engine.RegFunction("double", 1, func(expr ...engine.ExprAST)float64 {
// when argc > 0,you can use the index value directly according to the number of parameters// without worrying about crossing the boundary.// use ExprASTResult to get the result of the ExprAST structure.return engine.ExprASTResult(expr[0]) * 2
})
辅助函数 e.g. abs, ceil, floor, sqrt, cbrt, max, min, noerr
提供自定义函数注册功能,注册后可以在表达式中使用
精确的数据计算
友好的错误消息 e.g.
input /> 123+89-0.0.9
ERROR: strconv.ParseFloat: parsing "0.0.9": invalid syntax
want '(' or '0-9' but get '0.0.9'
------------
123+89-0.0.9
^
------------
FAQs
Unknown package
Package last updated on 23 Aug 2023
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.