aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/go-ini/ini/section.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/go-ini/ini/section.go')
-rw-r--r--vendor/github.com/go-ini/ini/section.go28
1 files changed, 22 insertions, 6 deletions
diff --git a/vendor/github.com/go-ini/ini/section.go b/vendor/github.com/go-ini/ini/section.go
index 806f149..94f7375 100644
--- a/vendor/github.com/go-ini/ini/section.go
+++ b/vendor/github.com/go-ini/ini/section.go
@@ -68,16 +68,18 @@ func (s *Section) NewKey(name, val string) (*Key, error) {
}
if inSlice(name, s.keyList) {
- s.keys[name].value = val
+ if s.f.options.AllowShadows {
+ if err := s.keys[name].addShadow(val); err != nil {
+ return nil, err
+ }
+ } else {
+ s.keys[name].value = val
+ }
return s.keys[name], nil
}
s.keyList = append(s.keyList, name)
- s.keys[name] = &Key{
- s: s,
- name: name,
- value: val,
- }
+ s.keys[name] = newKey(s, name, val)
s.keysHash[name] = val
return s.keys[name], nil
}
@@ -230,3 +232,17 @@ func (s *Section) DeleteKey(name string) {
}
}
}
+
+// ChildSections returns a list of child sections of current section.
+// For example, "[parent.child1]" and "[parent.child12]" are child sections
+// of section "[parent]".
+func (s *Section) ChildSections() []*Section {
+ prefix := s.name + "."
+ children := make([]*Section, 0, 3)
+ for _, name := range s.f.sectionList {
+ if strings.HasPrefix(name, prefix) {
+ children = append(children, s.f.sections[name])
+ }
+ }
+ return children
+}