mirror of
https://github.com/mjl-/mox.git
synced 2024-12-26 08:23:48 +03:00
update to latest sconf, for improved error messages for mixed tab/space indenting in config files
based on chat with niklas/broitzer
This commit is contained in:
parent
aef99a72d8
commit
dde2258f69
4 changed files with 22 additions and 12 deletions
2
go.mod
2
go.mod
|
@ -6,7 +6,7 @@ require (
|
||||||
github.com/mjl-/adns v0.0.0-20240509092456-2dc8715bf4af
|
github.com/mjl-/adns v0.0.0-20240509092456-2dc8715bf4af
|
||||||
github.com/mjl-/autocert v0.0.0-20231214125928-31b7400acb05
|
github.com/mjl-/autocert v0.0.0-20231214125928-31b7400acb05
|
||||||
github.com/mjl-/bstore v0.0.6
|
github.com/mjl-/bstore v0.0.6
|
||||||
github.com/mjl-/sconf v0.0.6
|
github.com/mjl-/sconf v0.0.7
|
||||||
github.com/mjl-/sherpa v0.6.7
|
github.com/mjl-/sherpa v0.6.7
|
||||||
github.com/mjl-/sherpadoc v0.0.16
|
github.com/mjl-/sherpadoc v0.0.16
|
||||||
github.com/mjl-/sherpaprom v0.0.2
|
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-/autocert v0.0.0-20231214125928-31b7400acb05/go.mod h1:taMFU86abMxKLPV4Bynhv8enbYmS67b8LG80qZv2Qus=
|
||||||
github.com/mjl-/bstore v0.0.6 h1:ntlu9MkfCkpm2XfBY4+Ws4KK9YzXzewr3+lCueFB+9c=
|
github.com/mjl-/bstore v0.0.6 h1:ntlu9MkfCkpm2XfBY4+Ws4KK9YzXzewr3+lCueFB+9c=
|
||||||
github.com/mjl-/bstore v0.0.6/go.mod h1:/cD25FNBaDfvL/plFRxI3Ba3E+wcB0XVOS8nJDqndg0=
|
github.com/mjl-/bstore v0.0.6/go.mod h1:/cD25FNBaDfvL/plFRxI3Ba3E+wcB0XVOS8nJDqndg0=
|
||||||
github.com/mjl-/sconf v0.0.6 h1:5Dt58488ZOoVx680zgK2K3vUrokLsp5mXDUACrJlrUc=
|
github.com/mjl-/sconf v0.0.7 h1:bdBcSFZCDFMm/UdBsgNCsjkYmKrSgYwp7rAOoufwHe4=
|
||||||
github.com/mjl-/sconf v0.0.6/go.mod h1:uF8OdWtLT8La3i4ln176i1pB0ps9pXGCaABEU55ZkE0=
|
github.com/mjl-/sconf v0.0.7/go.mod h1:uF8OdWtLT8La3i4ln176i1pB0ps9pXGCaABEU55ZkE0=
|
||||||
github.com/mjl-/sherpa v0.6.7 h1:C5F8XQdV5nCuS4fvB+ye/ziUQrajEhOoj/t2w5T14BY=
|
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-/sherpa v0.6.7/go.mod h1:dSpAOdgpwdqQZ72O4n3EHo/tR68eKyan8tYYraUMPNc=
|
||||||
github.com/mjl-/sherpadoc v0.0.0-20190505200843-c0a7f43f5f1d/go.mod h1:5khTKxoKKNXcB8bkVUO6GlzC7PFtMmkHq578lPbmnok=
|
github.com/mjl-/sherpadoc v0.0.0-20190505200843-c0a7f43f5f1d/go.mod h1:5khTKxoKKNXcB8bkVUO6GlzC7PFtMmkHq578lPbmnok=
|
||||||
|
|
26
vendor/github.com/mjl-/sconf/parse.go
generated
vendored
26
vendor/github.com/mjl-/sconf/parse.go
generated
vendored
|
@ -225,20 +225,24 @@ func (p *parser) parseStruct0(v reflect.Value) {
|
||||||
var more string
|
var more string
|
||||||
if strings.TrimSpace(s) == "" {
|
if strings.TrimSpace(s) == "" {
|
||||||
more = " (perhaps stray whitespace)"
|
more = " (perhaps stray whitespace)"
|
||||||
|
} else if strings.HasPrefix(l[0], " ") {
|
||||||
|
more = " (perhaps mixed tab/space indenting)"
|
||||||
}
|
}
|
||||||
p.stop(fmt.Sprintf("missing colon for key/value on non-empty line %q%s", origs, more))
|
p.stop(fmt.Sprintf("missing colon for struct key/value on non-empty line %q%s", origs, more))
|
||||||
}
|
}
|
||||||
k := l[0]
|
k := l[0]
|
||||||
if k == "" {
|
if k == "" {
|
||||||
p.stop("empty key")
|
p.stop("empty key in struct")
|
||||||
|
} else if strings.HasPrefix(k, " ") {
|
||||||
|
p.stop("key in struct starting with space (perhaps mixed tab/space indenting)")
|
||||||
}
|
}
|
||||||
if _, ok := seen[k]; ok {
|
if _, ok := seen[k]; ok {
|
||||||
p.stop("duplicate key")
|
p.stop("duplicate key in struct")
|
||||||
}
|
}
|
||||||
seen[k] = struct{}{}
|
seen[k] = struct{}{}
|
||||||
s = l[1]
|
s = l[1]
|
||||||
if s != "" && !strings.HasPrefix(s, " ") {
|
if s != "" && !strings.HasPrefix(s, " ") {
|
||||||
p.stop("missing space after colon")
|
p.stop("missing space after colon in struct")
|
||||||
}
|
}
|
||||||
if s != "" {
|
if s != "" {
|
||||||
s = s[1:]
|
s = s[1:]
|
||||||
|
@ -288,20 +292,26 @@ func (p *parser) parseMap0(v reflect.Value) {
|
||||||
var more string
|
var more string
|
||||||
if strings.TrimSpace(s) == "" {
|
if strings.TrimSpace(s) == "" {
|
||||||
more = " (perhaps stray whitespace)"
|
more = " (perhaps stray whitespace)"
|
||||||
|
} else if strings.HasPrefix(l[0], " ") {
|
||||||
|
more = " (perhaps mixed tab/space indenting)"
|
||||||
}
|
}
|
||||||
p.stop(fmt.Sprintf("missing colon for key/value on non-empty line %q%s", origs, more))
|
p.stop(fmt.Sprintf("missing colon for map key/value on non-empty line %q%s", origs, more))
|
||||||
}
|
}
|
||||||
k := l[0]
|
k := l[0]
|
||||||
if k == "" {
|
if k == "" {
|
||||||
p.stop("empty key")
|
p.stop("empty key in map")
|
||||||
}
|
}
|
||||||
if _, ok := seen[k]; ok {
|
if _, ok := seen[k]; ok {
|
||||||
p.stop("duplicate key")
|
p.stop("duplicate key in map")
|
||||||
}
|
}
|
||||||
seen[k] = struct{}{}
|
seen[k] = struct{}{}
|
||||||
s = l[1]
|
s = l[1]
|
||||||
if s != "" && !strings.HasPrefix(s, " ") {
|
if s != "" && !strings.HasPrefix(s, " ") {
|
||||||
p.stop("missing space after colon")
|
var more string
|
||||||
|
if strings.HasPrefix(k, " ") {
|
||||||
|
more = " (key starts with space, perhaps mixed tab/space indenting)"
|
||||||
|
}
|
||||||
|
p.stop("missing space after colon in map" + more)
|
||||||
}
|
}
|
||||||
if s != "" {
|
if s != "" {
|
||||||
s = s[1:]
|
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.6
|
# github.com/mjl-/bstore v0.0.6
|
||||||
## explicit; go 1.19
|
## explicit; go 1.19
|
||||||
github.com/mjl-/bstore
|
github.com/mjl-/bstore
|
||||||
# github.com/mjl-/sconf v0.0.6
|
# github.com/mjl-/sconf v0.0.7
|
||||||
## explicit; go 1.12
|
## explicit; go 1.12
|
||||||
github.com/mjl-/sconf
|
github.com/mjl-/sconf
|
||||||
# github.com/mjl-/sherpa v0.6.7
|
# github.com/mjl-/sherpa v0.6.7
|
||||||
|
|
Loading…
Reference in a new issue