mirror of
https://github.com/charlienet/go-mixed.git
synced 2025-07-18 00:22:41 +08:00
oops
This commit is contained in:
@ -2,6 +2,7 @@ package structs
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"strings"
|
||||
|
||||
"github.com/charlienet/go-mixed/expr"
|
||||
)
|
||||
@ -20,10 +21,20 @@ func parseField(fi reflect.StructField, opt option) field {
|
||||
name: fi.Name,
|
||||
tagName: expr.If(isValidTag(name), name, expr.If(opt.NameConverter != nil, opt.NameConverter(fi.Name), fi.Name)),
|
||||
ignoreEmpty: opt.IgnoreEmpty || (opts.Contains("omitempty") && opt.Omitempty),
|
||||
ignore: name == "-" && opt.Ignore,
|
||||
ignore: (name == "-" && opt.Ignore) || isSkipField(fi.Name, opt.SkipFields),
|
||||
}
|
||||
}
|
||||
|
||||
func (f field) shouldIgnore(s reflect.Value) bool {
|
||||
return f.ignore || (s.IsZero() && f.ignoreEmpty)
|
||||
}
|
||||
|
||||
func isSkipField(name string, skips []string) bool {
|
||||
for _, v := range skips {
|
||||
if strings.EqualFold(v, name) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
Reference in New Issue
Block a user