Add support for yml extension
diff --git a/viper.go b/viper.go
index 01471d9..cfadfc6 100644
--- a/viper.go
+++ b/viper.go
@@ -223,7 +223,7 @@
buf.ReadFrom(in)
switch getConfigType() {
- case "yaml":
+ case "yaml", "yml":
if err := yaml.Unmarshal(buf.Bytes(), &config); err != nil {
jww.ERROR.Fatalf("Error parsing config: %s", err)
}
@@ -399,7 +399,7 @@
configName = "config"
// extensions Supported
- SupportedExts = []string{"json", "toml", "yaml"}
+ SupportedExts = []string{"json", "toml", "yaml", "yml"}
configFile = ""
configType = ""
diff --git a/viper_test.go b/viper_test.go
index 01beac9..c5fe738 100644
--- a/viper_test.go
+++ b/viper_test.go
@@ -83,6 +83,15 @@
assert.Equal(t, 45, Get("age"))
}
+func TestYML(t *testing.T) {
+ Reset()
+ SetConfigType("yml")
+ r := bytes.NewReader(yamlExample)
+
+ MarshallReader(r)
+ assert.Equal(t, "steve", Get("name"))
+}
+
func TestJSON(t *testing.T) {
SetConfigType("json")
r := bytes.NewReader(jsonExample)