-
Notifications
You must be signed in to change notification settings - Fork 1
/
xgo.go
34 lines (30 loc) · 907 Bytes
/
xgo.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
package xgo
import (
"reflect"
"strings"
)
// IsFirstUpper determines whether the first letter is upper case
func IsFirstUpper(v string) bool {
if len(v) == 0 {
return false
}
return strings.HasPrefix(v, strings.ToUpper(string(v[0])))
}
// IsBlank determines whether the object is blank or sero value
func IsBlank(value reflect.Value) bool {
switch value.Kind() {
case reflect.String:
return value.IsZero()
case reflect.Bool:
return value.IsZero()
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
return value.IsZero()
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
return value.IsZero()
case reflect.Float32, reflect.Float64:
return value.IsZero()
case reflect.Interface, reflect.Ptr:
return value.IsNil()
}
return reflect.DeepEqual(value.Interface(), reflect.Zero(value.Type()).Interface())
}