govaluate
govaluate copied to clipboard
How to implement output the current time
For example, the expression:time.Now().Format("2006-01-02 15:04:05"),Is it supported?
functions := map[string]govaluate.ExpressionFunction {
"timeFormat": func(args ...interface{}) (interface{}, error) {
return time.Now().Format("2006-01-02 15:04:05"), nil
},
}
expString := "timeFormat()"
expression, _ := govaluate.NewEvaluableExpressionWithFunctions(expString, functions)
result, _ := expression.Evaluate(nil)