service/bizcommon/util/check.go

28 lines
850 B
Go

package util
import "reflect"
func IsTypeString(fieldType reflect.Type) bool {
return fieldType.Kind() == reflect.String
}
func IsTypeStringPtr(fieldType reflect.Type) bool {
return fieldType.Kind() == reflect.Pointer && fieldType.Elem().Kind() == reflect.String
}
func IsTypeByteSlice(fieldType reflect.Type) bool {
return fieldType.Kind() == reflect.Slice && fieldType.Elem().Kind() == reflect.Uint8
}
func IsTypeStruct(fieldType reflect.Type) bool {
return fieldType.Kind() == reflect.Struct
}
func IsTypeStructPtr(fieldType reflect.Type) bool {
return fieldType.Kind() == reflect.Pointer && fieldType.Elem().Kind() == reflect.Struct
}
func IsTypeStructPtrSlice(fieldType reflect.Type) bool {
return fieldType.Kind() == reflect.Slice && fieldType.Elem().Kind() == reflect.Pointer && fieldType.Elem().Elem().Kind() == reflect.Struct
}