message search
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user