mirror of
https://github.com/mjl-/mox.git
synced 2024-12-26 16:33:47 +03:00
update to latest sconf, which now gives more helpful error messages about some invalid config lines, like one with only whitespace
from arnt & friend, thanks for reporting!
This commit is contained in:
parent
0262f4621e
commit
6516a27689
4 changed files with 25 additions and 13 deletions
2
go.mod
2
go.mod
|
@ -6,7 +6,7 @@ require (
|
|||
github.com/mjl-/adns v0.0.0-20240309142737-2a1aacf346dc
|
||||
github.com/mjl-/autocert v0.0.0-20231214125928-31b7400acb05
|
||||
github.com/mjl-/bstore v0.0.4
|
||||
github.com/mjl-/sconf v0.0.5
|
||||
github.com/mjl-/sconf v0.0.6
|
||||
github.com/mjl-/sherpa v0.6.7
|
||||
github.com/mjl-/sherpadoc v0.0.12
|
||||
github.com/mjl-/sherpaprom v0.0.2
|
||||
|
|
4
go.sum
4
go.sum
|
@ -30,8 +30,8 @@ github.com/mjl-/autocert v0.0.0-20231214125928-31b7400acb05 h1:s6ay4bh4tmpPLdxjy
|
|||
github.com/mjl-/autocert v0.0.0-20231214125928-31b7400acb05/go.mod h1:taMFU86abMxKLPV4Bynhv8enbYmS67b8LG80qZv2Qus=
|
||||
github.com/mjl-/bstore v0.0.4 h1:q+R1oAr8+E9yf9q+zxkVjQ18VFqD/E9KmGVoe4FIOBA=
|
||||
github.com/mjl-/bstore v0.0.4/go.mod h1:/cD25FNBaDfvL/plFRxI3Ba3E+wcB0XVOS8nJDqndg0=
|
||||
github.com/mjl-/sconf v0.0.5 h1:4CMUTENpSnaeP2g6RKtrs8udTxnJgjX2MCCovxGId6s=
|
||||
github.com/mjl-/sconf v0.0.5/go.mod h1:uF8OdWtLT8La3i4ln176i1pB0ps9pXGCaABEU55ZkE0=
|
||||
github.com/mjl-/sconf v0.0.6 h1:5Dt58488ZOoVx680zgK2K3vUrokLsp5mXDUACrJlrUc=
|
||||
github.com/mjl-/sconf v0.0.6/go.mod h1:uF8OdWtLT8La3i4ln176i1pB0ps9pXGCaABEU55ZkE0=
|
||||
github.com/mjl-/sherpa v0.6.7 h1:C5F8XQdV5nCuS4fvB+ye/ziUQrajEhOoj/t2w5T14BY=
|
||||
github.com/mjl-/sherpa v0.6.7/go.mod h1:dSpAOdgpwdqQZ72O4n3EHo/tR68eKyan8tYYraUMPNc=
|
||||
github.com/mjl-/sherpadoc v0.0.0-20190505200843-c0a7f43f5f1d/go.mod h1:5khTKxoKKNXcB8bkVUO6GlzC7PFtMmkHq578lPbmnok=
|
||||
|
|
30
vendor/github.com/mjl-/sconf/parse.go
generated
vendored
30
vendor/github.com/mjl-/sconf/parse.go
generated
vendored
|
@ -218,11 +218,15 @@ func (p *parser) parseStruct0(v reflect.Value) {
|
|||
var zeroValue reflect.Value
|
||||
t := v.Type()
|
||||
for p.next() {
|
||||
s := p.string()
|
||||
s = s[len(p.prefix):]
|
||||
origs := p.string()
|
||||
s := origs[len(p.prefix):]
|
||||
l := strings.SplitN(s, ":", 2)
|
||||
if len(l) != 2 {
|
||||
p.stop("missing key: value")
|
||||
var more string
|
||||
if strings.TrimSpace(s) == "" {
|
||||
more = " (perhaps stray whitespace)"
|
||||
}
|
||||
p.stop(fmt.Sprintf("missing colon for key/value on non-empty line %q%s", origs, more))
|
||||
}
|
||||
k := l[0]
|
||||
if k == "" {
|
||||
|
@ -234,7 +238,7 @@ func (p *parser) parseStruct0(v reflect.Value) {
|
|||
seen[k] = struct{}{}
|
||||
s = l[1]
|
||||
if s != "" && !strings.HasPrefix(s, " ") {
|
||||
p.stop("no space after colon")
|
||||
p.stop("missing space after colon")
|
||||
}
|
||||
if s != "" {
|
||||
s = s[1:]
|
||||
|
@ -243,7 +247,11 @@ func (p *parser) parseStruct0(v reflect.Value) {
|
|||
|
||||
vv := v.FieldByName(k)
|
||||
if vv == zeroValue {
|
||||
p.stop(fmt.Sprintf("unknown key %q", k))
|
||||
var more string
|
||||
if strings.TrimSpace(k) != k {
|
||||
more = " (perhaps stray whitespace in key)"
|
||||
}
|
||||
p.stop(fmt.Sprintf("unknown key %q%s", k, more))
|
||||
}
|
||||
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))
|
||||
|
@ -273,11 +281,15 @@ func (p *parser) parseMap0(v reflect.Value) {
|
|||
seen := map[string]struct{}{}
|
||||
t := v.Type()
|
||||
for p.next() {
|
||||
s := p.string()
|
||||
s = s[len(p.prefix):]
|
||||
origs := p.string()
|
||||
s := origs[len(p.prefix):]
|
||||
l := strings.SplitN(s, ":", 2)
|
||||
if len(l) != 2 {
|
||||
p.stop("missing key: value")
|
||||
var more string
|
||||
if strings.TrimSpace(s) == "" {
|
||||
more = " (perhaps stray whitespace)"
|
||||
}
|
||||
p.stop(fmt.Sprintf("missing colon for key/value on non-empty line %q%s", origs, more))
|
||||
}
|
||||
k := l[0]
|
||||
if k == "" {
|
||||
|
@ -289,7 +301,7 @@ func (p *parser) parseMap0(v reflect.Value) {
|
|||
seen[k] = struct{}{}
|
||||
s = l[1]
|
||||
if s != "" && !strings.HasPrefix(s, " ") {
|
||||
p.stop("no space after colon")
|
||||
p.stop("missing space after colon")
|
||||
}
|
||||
if s != "" {
|
||||
s = s[1:]
|
||||
|
|
2
vendor/modules.txt
vendored
2
vendor/modules.txt
vendored
|
@ -19,7 +19,7 @@ github.com/mjl-/autocert
|
|||
# github.com/mjl-/bstore v0.0.4
|
||||
## explicit; go 1.19
|
||||
github.com/mjl-/bstore
|
||||
# github.com/mjl-/sconf v0.0.5
|
||||
# github.com/mjl-/sconf v0.0.6
|
||||
## explicit; go 1.12
|
||||
github.com/mjl-/sconf
|
||||
# github.com/mjl-/sherpa v0.6.7
|
||||
|
|
Loading…
Reference in a new issue