add comment about the sconf config file format at the top of the config files

hopefully this helps admins editing the file and prevent mistakes about config files.

for issue #56 by kikoreis, thanks!
This commit is contained in:
Mechiel Lukkien
2023-09-21 08:59:10 +02:00
parent 0d8603f9e1
commit 9534e464f9
8 changed files with 65 additions and 25 deletions

View File

@ -245,8 +245,8 @@ func (p *parser) parseStruct0(v reflect.Value) {
if vv == zeroValue {
p.stop(fmt.Sprintf("unknown key %q", k))
}
if ft, _ := t.FieldByName(k); isIgnore(ft.Tag.Get("sconf")) {
p.stop(fmt.Sprintf("unknown key %q (has ignore tag)", k))
if ft, _ := t.FieldByName(k); !ft.IsExported() || isIgnore(ft.Tag.Get("sconf")) {
p.stop(fmt.Sprintf("unknown key %q (has ignore tag or not exported)", k))
}
vv.Set(p.parseValue(vv))
}
@ -254,7 +254,7 @@ func (p *parser) parseStruct0(v reflect.Value) {
n := t.NumField()
for i := 0; i < n; i++ {
f := t.Field(i)
if isIgnore(f.Tag.Get("sconf")) || isOptional(f.Tag.Get("sconf")) {
if !f.IsExported() || isIgnore(f.Tag.Get("sconf")) || isOptional(f.Tag.Get("sconf")) {
continue
}
if _, ok := seen[f.Name]; !ok {