|
1
|
|
|
package gotil |
|
2
|
|
|
|
|
3
|
|
|
import "github.com/gotilty/gotil/internal" |
|
4
|
|
|
|
|
5
|
|
|
// IsAssigned checks the given parameter has value also if it's slice or array that checks has element. |
|
6
|
|
|
// Example: |
|
7
|
|
|
// result := IsAssigned("test data") |
|
8
|
|
|
// // Output: true |
|
9
|
|
|
func IsAssigned(a interface{}) bool { |
|
10
|
|
|
return internal.IsAssigned(a) |
|
11
|
|
|
} |
|
12
|
|
|
|
|
13
|
|
|
// IsNotAssigned checks the given parameter has not value also if it's slice or array that checks has not any element. |
|
14
|
|
|
// It works same IsEmpty() |
|
15
|
|
|
// Example: |
|
16
|
|
|
// result := IsNotAssigned("test data") |
|
17
|
|
|
// // Output: false |
|
18
|
|
|
func IsNotAssigned(a interface{}) bool { |
|
19
|
|
|
return internal.IsNotAssigned(a) |
|
20
|
|
|
} |
|
21
|
|
|
|
|
22
|
|
|
// IsArray checks the given parameter is an array |
|
23
|
|
|
func IsArray(a interface{}) bool { |
|
24
|
|
|
return internal.IsArray(a) |
|
25
|
|
|
|
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
// IsSlice checks the given parameter is a slice |
|
29
|
|
|
func IsSlice(a interface{}) bool { |
|
30
|
|
|
return internal.IsSlice(a) |
|
31
|
|
|
|
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
// IsString checks the given parameter is a string |
|
35
|
|
|
func IsString(a interface{}) bool { |
|
36
|
|
|
return internal.IsString(a) |
|
37
|
|
|
|
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
// IsBool checks the given parameter is a bool |
|
41
|
|
|
func IsBool(a interface{}) bool { |
|
42
|
|
|
return internal.IsBool(a) |
|
43
|
|
|
|
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
// IsInteger checks the given parameter is an integer |
|
47
|
|
|
// int, int8, int16, int32, int64, uint, uint8, uint16, uint32, unit64 |
|
48
|
|
|
func IsInteger(a interface{}) bool { |
|
49
|
|
|
return internal.IsInteger(a) |
|
50
|
|
|
|
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
// IsFloat checks the given parameter is an float |
|
54
|
|
|
// float32, float64 |
|
55
|
|
|
func IsFloat(a interface{}) bool { |
|
56
|
|
|
return internal.IsFloat(a) |
|
57
|
|
|
|
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
// IsNumber checks the given parameter is type of any golang number |
|
61
|
|
|
// int, int8, int16, int32, int64, uint, uint8, uint16, uint32, unit64, float32, float64 |
|
62
|
|
|
func IsNumber(a interface{}) bool { |
|
63
|
|
|
return internal.IsNumber(a) |
|
64
|
|
|
|
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
//IsFunc checks the given parameter is a func |
|
68
|
|
|
//int, int8, int16, int32, int64, uint, uint8, uint16, uint32, unit64, float32, float64 |
|
69
|
|
|
func IsFunc(a interface{}) bool { |
|
70
|
|
|
return internal.IsFunc(a) |
|
71
|
|
|
|
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
// IsStruct checks the given parameter is a struct |
|
75
|
|
|
func IsStruct(a interface{}) bool { |
|
76
|
|
|
return internal.IsStruct(a) |
|
77
|
|
|
|
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
// IsPointer checks the given parameter is a pointer |
|
81
|
|
|
func IsPointer(a interface{}) bool { |
|
82
|
|
|
return internal.IsPointer(a) |
|
83
|
|
|
|
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
// IsChan checks the given parameter is a channel |
|
87
|
|
|
func IsChan(a interface{}) bool { |
|
88
|
|
|
return internal.IsChan(a) |
|
89
|
|
|
|
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
// IsMap checks the given parameter is a map |
|
93
|
|
|
func IsMap(a interface{}) bool { |
|
94
|
|
|
return internal.IsMap(a) |
|
95
|
|
|
|
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
// IsByteArray checks the given parameter is a byte array |
|
99
|
|
|
func IsByteArray(a interface{}) bool { |
|
100
|
|
|
return internal.IsByteArray(a) |
|
101
|
|
|
|
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
// IsEqual checks the given any 2 parameters are equal |
|
105
|
|
|
func IsEqual(a interface{}, b interface{}) bool { |
|
106
|
|
|
return internal.IsEqual(a, b) |
|
107
|
|
|
|
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
|
|
// IsEmpty checks the given parameter has not value also if it's slice or array that checks has not any element. |
|
111
|
|
|
// It works same IsNotAssigned() |
|
112
|
|
|
func IsEmpty(a interface{}, b interface{}) bool { |
|
113
|
|
|
return internal.IsEmpty(a, b) |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
// IsNil checks the given parameter has not value also if it's slice or array that checks has not any element. |
|
117
|
|
|
// It works same IsNotAssigned() |
|
118
|
|
|
func IsNil(a interface{}, b interface{}) bool { |
|
119
|
|
|
return internal.IsNil(a, b) |
|
120
|
|
|
} |
|
121
|
|
|
|
|
122
|
|
|
// Size returns a length of given parameter |
|
123
|
|
|
// data := []int64{100, 30, -100, -5} |
|
124
|
|
|
// result, _ := Size(data) |
|
125
|
|
|
// result2, _ := Size("gotil") |
|
126
|
|
|
// // Output: 4 |
|
127
|
|
|
// // Output2: 5 |
|
128
|
|
|
func Size(val interface{}) (int, error) { |
|
129
|
|
|
return internal.Size(val) |
|
130
|
|
|
} |
|
131
|
|
|
|