1
0
Fork 0
mirror of https://github.com/Luzifer/korvike.git synced 2024-11-14 02:02:41 +00:00
korvike/vendor/github.com/Luzifer/rconfig/vardefault_providers.go
Knut Ahlers 6a7a769b17
Add dependencies
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2017-02-14 12:18:02 +01:00

27 lines
598 B
Go

package rconfig
import (
"io/ioutil"
"gopkg.in/yaml.v2"
)
// VarDefaultsFromYAMLFile reads contents of a file and calls VarDefaultsFromYAML
func VarDefaultsFromYAMLFile(filename string) map[string]string {
data, err := ioutil.ReadFile(filename)
if err != nil {
return make(map[string]string)
}
return VarDefaultsFromYAML(data)
}
// VarDefaultsFromYAML creates a vardefaults map from YAML raw data
func VarDefaultsFromYAML(in []byte) map[string]string {
out := make(map[string]string)
err := yaml.Unmarshal(in, &out)
if err != nil {
return make(map[string]string)
}
return out
}