From 7861cf148e9f76614d115afe521994023047ccc7 Mon Sep 17 00:00:00 2001 From: Brian Picciano Date: Mon, 13 Aug 2018 11:50:57 -0400 Subject: [PATCH] mcfg: always lowercase param and child names --- mcfg/mcfg.go | 1 + mcfg/param.go | 2 ++ 2 files changed, 3 insertions(+) diff --git a/mcfg/mcfg.go b/mcfg/mcfg.go index 1e0ea64..2507371 100644 --- a/mcfg/mcfg.go +++ b/mcfg/mcfg.go @@ -254,6 +254,7 @@ func (c *Cfg) StopRun(ctx context.Context) error { // prepended to all configuration options created in the returned sub-Cfg, and // must not be empty. func (c *Cfg) Child(name string) *Cfg { + name = strings.ToLower(name) if _, ok := c.Children[name]; ok { panic(fmt.Sprintf("child Cfg named %q already exists", name)) } diff --git a/mcfg/param.go b/mcfg/param.go index 1290aed..eca6ebe 100644 --- a/mcfg/param.go +++ b/mcfg/param.go @@ -2,6 +2,7 @@ package mcfg import ( "fmt" + "strings" "github.com/mediocregopher/mediocre-go-lib/mtime" ) @@ -40,6 +41,7 @@ type Param struct { // ParamAdd adds the given Param to the Cfg. It will panic if a Param of the // same Name already exists in the Cfg. func (c *Cfg) ParamAdd(p Param) { + p.Name = strings.ToLower(p.Name) if _, ok := c.Params[p.Name]; ok { panic(fmt.Sprintf("Cfg.Path:%#v name:%q already exists", c.Path, p.Name)) }