message search (#60)

This commit is contained in:
Sarv
2025-04-19 03:06:05 +08:00
committed by GitHub
parent 85b5465d2a
commit a745519451
19 changed files with 910 additions and 519 deletions

View File

@@ -3,6 +3,7 @@ package util
import (
"fmt"
"strconv"
"strings"
"unicode"
"unicode/utf8"
)
@@ -45,3 +46,26 @@ func IsNumeric(s string) bool {
func SplitInt64ToTwoInt32(input int64) (int64, int64) {
return input & 0xFFFFFFFF, input >> 32
}
func Str2List(str string, sep string) []string {
list := make([]string, 0)
if str == "" {
return list
}
listMap := make(map[string]bool)
for _, elem := range strings.Split(str, sep) {
elem = strings.TrimSpace(elem)
if len(elem) == 0 {
continue
}
if _, ok := listMap[elem]; ok {
continue
}
listMap[elem] = true
list = append(list, elem)
}
return list
}