package rest import ( "git.nobla.cn/golang/kos/util/arrays" "reflect" "strings" ) func hasToken(hack string, need string) bool { if len(need) == 0 || len(hack) == 0 { return false } char := []byte{',', ';'} for _, c := range char { if strings.IndexByte(need, c) > -1 { return arrays.Exists(hack, strings.Split(need, string(c))) } } return false } func isEmpty(val any) bool { if val == nil { return true } v := reflect.ValueOf(val) switch v.Kind() { case reflect.String, reflect.Array: return v.Len() == 0 case reflect.Map, reflect.Slice: return v.IsNil() || v.Len() == 0 case reflect.Bool: return !v.Bool() case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: return v.Int() == 0 case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: return v.Uint() == 0 case reflect.Float32, reflect.Float64: return v.Float() == 0 case reflect.Interface, reflect.Ptr: return v.IsNil() default: return reflect.DeepEqual(val, reflect.Zero(v.Type()).Interface()) } }