Add new function ShadowLoad

This commit is contained in:
Unknwon
2017-02-22 06:10:43 -05:00
parent 173c8ba8e6
commit 74bdc99692
2 changed files with 8 additions and 2 deletions
+7 -1
View File
@@ -37,7 +37,7 @@ const (
// Maximum allowed depth when recursively substituing variable names.
_DEPTH_VALUES = 99
_VERSION = "1.25.1"
_VERSION = "1.25.2"
)
// Version returns current package version literal.
@@ -221,6 +221,12 @@ func InsensitiveLoad(source interface{}, others ...interface{}) (*File, error) {
return LoadSources(LoadOptions{Insensitive: true}, source, others...)
}
// InsensitiveLoad has exactly same functionality as Load function
// except it allows have shadow keys.
func ShadowLoad(source interface{}, others ...interface{}) (*File, error) {
return LoadSources(LoadOptions{AllowShadows: true}, source, others...)
}
// Empty returns an empty file object.
func Empty() *File {
// Ignore error here, we sure our data is good.
+1 -1
View File
@@ -455,7 +455,7 @@ func Test_Key_Shadows(t *testing.T) {
})
Convey("Enable shadows", func() {
cfg, err := LoadSources(LoadOptions{AllowShadows: true}, []byte(_CONF_GIT_CONFIG))
cfg, err := ShadowLoad([]byte(_CONF_GIT_CONFIG))
So(err, ShouldBeNil)
So(cfg.Section(`remote "origin"`).Key("url").String(), ShouldEqual, "https://github.com/Antergone/test1.git")
So(strings.Join(cfg.Section(`remote "origin"`).Key("url").ValueWithShadows(), " "), ShouldEqual,