Documentation ¶
Index ¶
- Variables
- func Eval(expression string, data interface{}) (string, error)
- func Match(expression string, data interface{}) (bool, error)
- func StringEval(expression string, data string) (string, error)
- func StringMatch(expression string, data string) (bool, error)
- type Data
- func (d Data) CtxJSON(path string) string
- func (d Data) CtxJSONArray(path string) []gjson.Result
- func (d Data) CtxJSONBool(path string) bool
- func (d Data) CtxJSONBoolArray(path string) []bool
- func (d Data) CtxJSONFloat(path string) float64
- func (d Data) CtxJSONFloatArray(path string) []float64
- func (d Data) CtxJSONInt(path string) int64
- func (d Data) CtxJSONIntArray(path string) []int64
- func (d Data) CtxJSONStrArray(path string) []string
- func (d Data) DOM(selector string, data ...string) []string
- func (d Data) DOMOne(selector string, index int, data ...string) string
- func (d Data) JQ(expression string, data ...string) string
- func (d Data) JQE(expression string, data ...string) string
- type Evaluator
- type Helpers
- func (Helpers) Between(val int, min int, max int) bool
- func (Helpers) CutOff(maxLen int, val string) string
- func (Helpers) CutoffLine(maxLine int, val string) string
- func (helper Helpers) DOMQuery(selector string, htmlContent string) []string
- func (helper Helpers) DOMQueryOne(selector string, index int, htmlContent string) string
- func (Helpers) DailyTimeBetween(startTime, endTime string) bool
- func (Helpers) Empty(str string) bool
- func (Helpers) EqualFold(s1, s2 string) bool
- func (Helpers) FilterEmptyLines(content string) string
- func (Helpers) Float(numStr string) float64
- func (Helpers) Int(numStr string) int
- func (helper Helpers) JQuery(data string, expression string, suppressError bool) string
- func (helper Helpers) JSON(content string, path string) string
- func (helper Helpers) JSONArray(content string, path string) []gjson.Result
- func (helper Helpers) JSONBool(content string, path string) bool
- func (helper Helpers) JSONBoolArray(content string, path string) []bool
- func (helper Helpers) JSONEncode(data interface{}) string
- func (helper Helpers) JSONFloat(content string, path string) float64
- func (helper Helpers) JSONFloatArray(content string, path string) []float64
- func (helper Helpers) JSONInt(content string, path string) int64
- func (helper Helpers) JSONIntArray(content string, path string) []int64
- func (helper Helpers) JSONStrArray(content string, path string) []string
- func (Helpers) Join(elements interface{}, sep string) string
- func (Helpers) Lower(val string) string
- func (Helpers) Mask(left int, content string) string
- func (Helpers) Now() time.Time
- func (Helpers) NumberBeauty(number interface{}) string
- func (Helpers) ParseTime(layout string, value string) time.Time
- func (Helpers) Repeat(count int, s string) string
- func (Helpers) Split(sep string, content string) []string
- func (helper Helpers) String(data interface{}) string
- func (Helpers) TrimPrefix(s, prefix string) string
- func (Helpers) TrimSpace(s string) string
- func (Helpers) TrimSuffix(s, suffix string) string
- func (Helpers) Upper(val string) string
- type Matcher
Constants ¶
This section is empty.
Variables ¶
var (
ErrInvalidReturnValType = errors.New("invalid return value type")
)
Functions ¶
func StringEval ¶
StringEval 对 data 应用表达式
Types ¶
type Data ¶
Data 封装了助手函数和匹配数据的结构体
func (Data) CtxJSONArray ¶
CtxJSONArray return array from json
func (Data) CtxJSONBool ¶
CtxJSONBool return bool from json
func (Data) CtxJSONBoolArray ¶
CtxJSONBoolArray return bool array from json
func (Data) CtxJSONFloat ¶
CtxJSONFloat return float64 from json
func (Data) CtxJSONFloatArray ¶
CtxJSONFloatArray return float64 array from json
func (Data) CtxJSONInt ¶
CtxJSONInt return int from json
func (Data) CtxJSONIntArray ¶
CtxJSONIntArray return int array from json
func (Data) CtxJSONStrArray ¶
CtxJSONStrArray get string array from json
type Evaluator ¶
type Evaluator struct {
// contains filtered or unexported fields
}
Evaluator 用于计算 data 在应用 expression 后的结果
func NewEvaluator ¶
NewEvaluator 创建一个新的 Evaluator
type Helpers ¶
type Helpers struct{}
Helpers 用于规则引擎的助手函数
func (Helpers) CutoffLine ¶
CutoffLine 字符串截取指定行数
func (Helpers) DOMQueryOne ¶
DOMQueryOne 从 HTML DOM 对象中查询第 index 个匹配 selector 的元素内容
func (Helpers) DailyTimeBetween ¶
DailyTimeBetween 判断当前时间(格式 15:04)是否在 startTime 和 endTime 之间
func (Helpers) EqualFold ¶
EqualFold reports whether s and t, interpreted as UTF-8 strings, are equal under Unicode case-folding, which is a more general form of case-insensitivity.
func (Helpers) FilterEmptyLines ¶
FilterEmptyLines 从字符串中移除空行
func (Helpers) JSONBoolArray ¶
JSONBoolArray return bool array from json
func (Helpers) JSONEncode ¶
func (Helpers) JSONFloatArray ¶
JSONFloatArray return float64 array from json
func (Helpers) JSONIntArray ¶
JSONIntArray return int64 array from json
func (Helpers) JSONStrArray ¶
JSONStrArray return string array from json
func (Helpers) Lower ¶
Lower returns a copy of the string s with all Unicode letters mapped to their lower case.
func (Helpers) NumberBeauty ¶
NumberBeauty 字符串数字格式化
func (Helpers) ParseTime ¶
ParseTime parse a string to time.Time layout: Mon Jan 2 15:04:05 -0700 MST 2006
type Matcher ¶
type Matcher struct {
// contains filtered or unexported fields
}
Matcher 用于检查 data 是否匹配表达式
func NewMatcher ¶
NewMatcher 创建一个新的 Matcher