add new tag ignore to prevent printing specific field

This commit is contained in:
Lan Phan 2024-09-13 15:31:51 +07:00
parent 25a2203000
commit dad7b53d9c

View File

@ -91,6 +91,9 @@ func PrintConfig(s interface{}, f io.Writer, style *table.Style, withColor bool,
continue continue
} }
if jtag := tt.Tag.Get("json"); jtag != "" && jtag != "-" { if jtag := tt.Tag.Get("json"); jtag != "" && jtag != "-" {
if ig := tt.Tag.Get("ignore"); ig == "true" {
continue
}
name := strings.Split(jtag, ",")[0] name := strings.Split(jtag, ",")[0]
if _, ok := redundantSet[name]; ok { if _, ok := redundantSet[name]; ok {
continue continue
@ -106,6 +109,9 @@ func PrintConfig(s interface{}, f io.Writer, style *table.Style, withColor bool,
} }
default: default:
name := strings.Split(jsonTag, ",")[0] name := strings.Split(jsonTag, ",")[0]
if ig := t.Tag.Get("ignore"); ig == "true" {
continue
}
if _, ok := redundantSet[name]; ok { if _, ok := redundantSet[name]; ok {
continue continue
} }