-
Notifications
You must be signed in to change notification settings - Fork 9
/
KfcSearchResult.go
34 lines (29 loc) · 1.17 KB
/
KfcSearchResult.go
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
package util
import (
"sync"
)
// KfcSearchResult 结构体
type KfcSearchResult struct {
// 匹配到的关键词的等级,值为null,或为A、B、C、D。<br/>当匹配不到关键词时,值为null,否则值为A、B、C、D中的一个。<br/>A、B、C、D等级按严重程度从高至低排列。
Level string `json:"level,omitempty" xml:"level,omitempty"`
// 过滤后的文本:<br/>当匹配到B等级的词时,文本中的关键词被替换为*号,content即为关键词替换后的文本;<br/>其他情况,content始终为null
Content string `json:"content,omitempty" xml:"content,omitempty"`
// 是否匹配到关键词,匹配到则为true.
Matched bool `json:"matched,omitempty" xml:"matched,omitempty"`
}
var poolKfcSearchResult = sync.Pool{
New: func() any {
return new(KfcSearchResult)
},
}
// GetKfcSearchResult() 从对象池中获取KfcSearchResult
func GetKfcSearchResult() *KfcSearchResult {
return poolKfcSearchResult.Get().(*KfcSearchResult)
}
// ReleaseKfcSearchResult 释放KfcSearchResult
func ReleaseKfcSearchResult(v *KfcSearchResult) {
v.Level = ""
v.Content = ""
v.Matched = false
poolKfcSearchResult.Put(v)
}