forked from foxundermoon/WechatHelper708
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils_string.go
More file actions
70 lines (58 loc) · 1.32 KB
/
utils_string.go
File metadata and controls
70 lines (58 loc) · 1.32 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package wxxx
import "strings"
func Trim(str *string) string {
if str == nil {
return ""
}
return strings.Trim(*str, " ")
}
func TrimStr(str string) string {
return strings.Trim(str, " ")
}
func IsEmpty(str *string) bool {
return str == nil || len(strings.Trim(*str, " ")) == 0
}
func IsEmptyStr(str string) bool {
return len(strings.Trim(str, " ")) == 0
}
//noinspection ALL
func IsNotEmpty(str *string) bool {
return !IsEmpty(str)
}
//noinspection ALL
func IsNotEmptyStr(str string) bool {
return !IsEmptyStr(str)
}
//noinspection ALL
func IsStrEqual(str1 string, str2 string) bool {
if IsEmptyStr(str1) && IsEmptyStr(str2) {
return true
}
return str1 == str2
}
//noinspection ALL
func IsStrNotEqual(str1 string, str2 string) bool {
return !IsStrEqual(str1, str2)
}
//noinspection ALL
func IsEqual(str1 *string, str2 *string) bool {
if IsEmpty(str1) && IsEmpty(str2) {
return true
}
return *str1 == *str2
}
//noinspection ALL
func IsNotEqual(str1 *string, str2 *string) bool {
return !IsEqual(str1, str2)
}
//noinspection ALL
func IsEqualStrIgnoreCase(str1 string, str2 string) bool {
if IsEmptyStr(str1) && IsEmptyStr(str2) {
return true
}
return strings.ToLower(TrimStr(str1)) == strings.ToLower(TrimStr(str2))
}
//noinspection ALL
func ToUpper(str string) string {
return strings.ToUpper(TrimStr(str))
}