attempt at using a config struct instead of the ini library
Added script to convert config-base.json into a go struct, so that access to config values and metadata could be unified and simpler. It probably won't see any actual use though as mapping the ini into it is painful.
This commit is contained in:
@@ -6,6 +6,32 @@ import (
|
||||
"strconv"
|
||||
)
|
||||
|
||||
/*var DeCamel ini.NameMapper = func(raw string) string {
|
||||
out := make([]rune, 0, len(raw))
|
||||
upper := 0
|
||||
for _, c := range raw {
|
||||
if unicode.IsUpper(c) {
|
||||
upper++
|
||||
}
|
||||
if upper == 2 {
|
||||
out = append(out, '_')
|
||||
upper = 0
|
||||
}
|
||||
out = append(out, unicode.ToLower(c))
|
||||
}
|
||||
return string(out)
|
||||
}
|
||||
|
||||
func (ctx *appContext) loadDefaults() (err error) {
|
||||
var cfb []byte
|
||||
cfb, err = ioutil.ReadFile(ctx.configBase_path)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
json.Unmarshal(cfb, ctx.defaults)
|
||||
return
|
||||
}*/
|
||||
|
||||
func (ctx *appContext) loadConfig() error {
|
||||
var err error
|
||||
ctx.config, err = ini.Load(ctx.config_path)
|
||||
|
||||
Reference in New Issue
Block a user