From 9b3600643bfba61116ca77651e983d7c1832011e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Thu, 2 Feb 2023 12:30:25 +0800 Subject: [PATCH] =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E8=A7=A3=E6=9E=90=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0MAP=20=E4=B8=8E=20SLICE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- reflect.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/reflect.go b/reflect.go index d67c24a..26a1da3 100644 --- a/reflect.go +++ b/reflect.go @@ -104,6 +104,10 @@ func (rt *ReflectType) fillFieldType(field *StructField, dataType reflect.Type) field.Type = reflect.String case reflect.Struct: field.Type = reflect.Struct + case reflect.Slice: + field.Type = reflect.Slice + case reflect.Map: + field.Type = reflect.Map case reflect.Ptr: field.IsPtr = true // 指针再次判断基础类型 @@ -285,6 +289,28 @@ func (rv *ReflectValue) isZeroInputFieldValue(reflectValue reflect.Value, fieldI } return true } + case reflect.Map: + if nil == inputVal { + return true + } + var m map[interface{}]interface{} + if err := util.ConvertAssign(&m, inputVal); nil == err { + if len(m) != 0 { + return false + } + return true + } + case reflect.Slice: + if nil == inputVal { + return true + } + var sl []interface{} + if err := util.ConvertAssign(&sl, inputVal); nil == err { + if len(sl) != 0 { + return false + } + return true + } case reflect.Interface: if inputVal == nil { return true