mirror of
https://github.com/spf13/viper
synced 2024-12-23 03:57:01 +00:00
we should let uesr decide when to exit the program
This commit is contained in:
parent
be5ff3e484
commit
e4dd0af974
1 changed files with 4 additions and 4 deletions
8
util.go
8
util.go
|
@ -126,24 +126,24 @@ func marshallConfigReader(in io.Reader, c map[string]interface{}, configType str
|
||||||
switch strings.ToLower(configType) {
|
switch strings.ToLower(configType) {
|
||||||
case "yaml", "yml":
|
case "yaml", "yml":
|
||||||
if err := yaml.Unmarshal(buf.Bytes(), &c); err != nil {
|
if err := yaml.Unmarshal(buf.Bytes(), &c); err != nil {
|
||||||
jww.ERROR.Fatalf("Error parsing config: %s", err)
|
jww.ERROR.Panicf("Error parsing config: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
case "json":
|
case "json":
|
||||||
if err := json.Unmarshal(buf.Bytes(), &c); err != nil {
|
if err := json.Unmarshal(buf.Bytes(), &c); err != nil {
|
||||||
jww.ERROR.Fatalf("Error parsing config: %s", err)
|
jww.ERROR.Panicf("Error parsing config: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
case "toml":
|
case "toml":
|
||||||
if _, err := toml.Decode(buf.String(), &c); err != nil {
|
if _, err := toml.Decode(buf.String(), &c); err != nil {
|
||||||
jww.ERROR.Fatalf("Error parsing config: %s", err)
|
jww.ERROR.Panicf("Error parsing config: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
case "properties", "props", "prop":
|
case "properties", "props", "prop":
|
||||||
var p *properties.Properties
|
var p *properties.Properties
|
||||||
var err error
|
var err error
|
||||||
if p, err = properties.Load(buf.Bytes(), properties.UTF8); err != nil {
|
if p, err = properties.Load(buf.Bytes(), properties.UTF8); err != nil {
|
||||||
jww.ERROR.Fatalf("Error parsing config: %s", err)
|
jww.ERROR.Panicf("Error parsing config: %s", err)
|
||||||
}
|
}
|
||||||
for _, key := range p.Keys() {
|
for _, key := range p.Keys() {
|
||||||
value, _ := p.Get(key)
|
value, _ := p.Get(key)
|
||||||
|
|
Loading…
Reference in a new issue