Merge pull request #1743 from lanphan/printconfig
Some checks failed
Go / build (1.21, 6.2) (push) Has been cancelled
golang-lint / lint (push) Has been cancelled

add new tag ignore to prevent printing specific field
This commit is contained in:
c9s 2024-10-28 21:13:13 +08:00 committed by GitHub
commit 58133d94ba
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

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