-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfilter.go
More file actions
56 lines (44 loc) · 767 Bytes
/
filter.go
File metadata and controls
56 lines (44 loc) · 767 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package uni_filter
import (
"errors"
"fmt"
)
const FieldParamSep = "="
const FieldOpSep = "__"
const FieldSep = "."
const OPParamsSep = "__"
type Key struct {
name string
}
func parseKey(s string) (*Key, error) {
if len(s) == 0 {
return nil, errors.New("empty key")
}
return &Key{
name: s,
}, nil
}
type Value struct {
S string // clean string
V any
}
type Filter struct {
// 原始未解析的 key
Key string
// 原始未解析的 value
Value string
// 解析后的 keys
keys []*Key
//// 从原始 key 中提取出来的 op
op OP
// 从原始 key 中提取到的 ! flag
opposite bool
}
func (f *Filter) String() string {
s := f.Key
if f.Value != "" {
s = fmt.Sprintf("%s=%s", s, f.Value)
}
// FIXME show about op
return s
}