8000 GitHub - hanshuaikang/bk-expr: bk-expr go语言表达式解析工具
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

hanshuaikang/bk-expr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BK-EXPR go语言表达式解析工具

数值计算

  • 取余

布尔计算

  • (==)
  • (>)
  • (<)
  • (>=)
  • (<=)

逻辑运算符

  • &&
  • ||
  • not

包含表达式

  • in
  • not in

日期计算

  • 比较运算符
  • 日期 - 日期 = 天数

自定义函数

  • @函数名(参数1,参数2, 参数3)

变量

  • $env # 注入上下文即可使用

示例:

// 运算符
expression := "1+1-1*1/2"

// 比较运算符
expression := "1>1"

//逻辑运算符
expression := "1>1 && 1==1"

// 包含表达式(现阶段只支持变量和字符串)
expression := "'本科' in $list "
ctx := map[string]interface{}{"list": []interface{}{"本科", "硕士"}}

// 字符串in计算
expression := "'本科' in '本科再往上是研究生' "

// 日期计算
expression := "'2022-01-21' - '2022-01-01'" //result: 20天
expression := "'2022-01-21' > '2022-01-01'" // result: true

// 函数类型, @now() 获取当前时间
expression := "@now() > '2022-01-01'"

About

bk-expr go语言表达式解析工具

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0