优化代码

This commit is contained in:
GoEdgeLab
2023-08-08 15:12:28 +08:00
parent a7a170f9c6
commit 98eac40783
21 changed files with 61 additions and 78 deletions

View File

@@ -7,7 +7,7 @@ import (
var whitespaceReg = regexp.MustCompile(`\s+`)
// 关键词匹配
// MatchKeyword 关键词匹配
func MatchKeyword(source, keyword string) bool {
if len(keyword) == 0 {
return false
@@ -16,7 +16,7 @@ func MatchKeyword(source, keyword string) bool {
pieces := whitespaceReg.Split(keyword, -1)
source = strings.ToLower(source)
for _, piece := range pieces {
if strings.Index(source, strings.ToLower(piece)) > -1 {
if strings.Contains(source, strings.ToLower(piece)) {
return true
}
}