func GetKindByValue(val reflect.Value) reflect.Kind {
	return GetKind(val.Kind())
}
GetKindByValue get kind by value
package reflector
import (
	"errors"
	"hidevops.io/hiboot/pkg/utils/io"
	"hidevops.io/hiboot/pkg/utils/str"
	"reflect"
	"runtime"
	"strings"
)
var (
	ErrInvalidInput = errors.New("input is invalid")
	ErrInvalidMethod = errors.New("method is invalid")
	ErrInvalidFunc = errors.New("func is invalid")
	ErrFieldCanNotBeSet = errors.New("field can not be set")
)
func NewReflectType(st interface{}) interface{} {
	ct := reflect.TypeOf(st)
	co := reflect.New(ct)
	cp := co.Elem().Addr().Interface()
	return cp
}
func Validate(toValue interface{}) (*reflect.Value, error) {
	to := Indirect(reflect.ValueOf(toValue))
	if !to.IsValid() {
		return nil, errors.New("value is not valid")
	}
	if !to.CanAddr() {
		return nil, errors.New("value is unaddressable")
	}
	return &to, nil
}
func DeepFields(reflectType reflect.Type) []reflect.StructField {
	var fields []reflect.StructField
	if reflectType = IndirectType(reflectType); reflectType.Kind() == reflect.Struct {
		for i := 0; i < reflectType.NumField(); i++ {
			v := reflectType.Field(i)
			if v.Anonymous {
				vk :=  IndirectType(v.Type).Kind()
				if vk != reflect.Struct && vk != reflect.Interface {
					fields = append(fields, v)
				} else {
					fields = append(fields, DeepFields(v.Type)...)
				}
			} else {
				fields = append(fields, v)
			}
		}
	}
	return fields
}
func Indirect(reflectValue reflect.Value) reflect.Value {
	for reflectValue.Kind() == reflect.Ptr {
		reflectValue = reflectValue.Elem()
	}
	return reflectValue
}
func IndirectValue(object interface{}) (reflectValue reflect.Value) {
	switch object.(type) {
	case reflect.Value:
		reflectValue = object.(reflect.Value)
	case reflect.Type:
		return
	default:
		reflectValue = reflect.ValueOf(object)
	}
	reflectValue = Indirect(reflectValue)
	return
}
func IndirectType(reflectType reflect.Type) reflect.Type {
	for reflectType.Kind() == reflect.Ptr || reflectType.Kind() == reflect.Slice {
		reflectType = reflectType.Elem()
	}
	return reflectType
}
func GetFieldValue(f interface{}, name string) reflect.Value {
	r := reflect.ValueOf(f)
	fv := reflect.Indirect(r).FieldByName(name)
	return fv
}
func FindFieldByTag(obj interface{}, key, name string) (field reflect.StructField, ok bool) {
	typ, ok := GetObjectType(obj)
	if ok {
		for _, f := range DeepFields(typ) {
			if f.Tag.Get(key) == name {
				field = f
				ok = true
				break
			}
		}
	}
	return
}
func SetFieldValue(object interface{}, name string, value interface{}) error {
	obj := Indirect(reflect.ValueOf(object))
	if !obj.IsValid() {
		return ErrInvalidInput
	}
	if obj.Kind() != reflect.Struct {
		return ErrInvalidInput
	}
	fieldObj := obj.FieldByName(name)
	if !fieldObj.CanSet() {
		return ErrFieldCanNotBeSet
	}
	fov := reflect.ValueOf(value)
	fieldObj.Set(fov)
	return nil
}
func GetKind(kind reflect.Kind) reflect.Kind {
	switch {
	case kind >= reflect.Int && kind <= reflect.Int64:
		return reflect.Int
	case kind >= reflect.Uint && kind <= reflect.Uint64:
		return reflect.Uint
	case kind >= reflect.Float32 && kind <= reflect.Float64:
		return reflect.Float32
	default:
		return kind
	}
}