-
Notifications
You must be signed in to change notification settings - Fork 927
/
goutil.go
65 lines (52 loc) · 1.04 KB
/
goutil.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
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
package common
import (
"strings"
)
func ContainsStringSlice(strs []string, search string) bool {
for _, v := range strs {
if v == search {
return true
}
}
return false
}
func ContainsStringSliceFold(strs []string, search string) bool {
for _, v := range strs {
if strings.EqualFold(v, search) {
return true
}
}
return false
}
func ContainsInt64Slice(slice []int64, search int64) bool {
for _, v := range slice {
if v == search {
return true
}
}
return false
}
// ContainsInt64SliceOneOf returns true if slice contains one of search
func ContainsInt64SliceOneOf(slice []int64, search []int64) bool {
for _, v := range search {
if ContainsInt64Slice(slice, v) {
return true
}
}
return false
}
func ContainsIntSlice(slice []int, search int) bool {
for _, v := range slice {
if v == search {
return true
}
}
return false
}
func IsNumber(v interface{}) bool {
switch v.(type) {
case int, int8, int16, int32, int64, uint, uint8, uint16, uint32, uint64, float32, float64:
return true
}
return false
}