File tree Expand file tree Collapse file tree 2 files changed +187
-83
lines changed Expand file tree Collapse file tree 2 files changed +187
-83
lines changed Original file line number Diff line number Diff line change @@ -9,7 +9,10 @@ import (
99 "github.com/zeromicro/go-zero/core/mapping"
1010)
1111
12- const tagName = "db"
12+ const (
13+ tagIgnore = "-"
14+ tagName = "db"
15+ )
1316
1417var (
1518 // ErrNotMatchDestination is an error that indicates not matching destination to scan.
@@ -269,21 +272,20 @@ func unwrapFields(v reflect.Value) []reflect.Value {
269272 continue
270273 }
271274
275+ childType := indirect .Type ().Field (i )
276+ if parseTagName (childType ) == tagIgnore {
277+ continue
278+ }
279+
272280 if child .Kind () == reflect .Ptr && child .IsNil () {
273281 baseValueType := mapping .Deref (child .Type ())
274282 child .Set (reflect .New (baseValueType ))
275283 }
276284
277285 child = reflect .Indirect (child )
278- childType := indirect .Type ().Field (i )
279286 if child .Kind () == reflect .Struct && childType .Anonymous {
280287 fields = append (fields , unwrapFields (child )... )
281288 } else {
282- key := parseTagName (childType )
283- if key == "-" {
284- continue
285- }
286-
287289 fields = append (fields , child )
288290 }
289291 }
You can’t perform that action at this time.
0 commit comments