Skip to content

Commit

Permalink
add all func for loop
Browse files Browse the repository at this point in the history
  • Loading branch information
janz.zhang committed Jan 17, 2017
1 parent 32c9e2c commit a4181a3
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions goconfigobj.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,16 @@ func (co *ConfigObj) Value(key string) string {
return co.baseSection.Value(key)
}

//AllSections return all sections
func (co *ConfigObj) AllSections() map[string]*Section {
return co.baseSection.AllSections()
}

//AllDatas return all key-value data
func (co *ConfigObj) AllDatas() map[string]string {
return co.baseSection.AllDatas()
}

//Section get section, if not have section, return nil
func (s *Section) Section(name string) *Section {
sect, ok := s.sects[name]
Expand All @@ -206,6 +216,16 @@ func (s *Section) SetValue(key, value string) {
s.data[key] = value
}

//AllSections return all sections
func (s *Section) AllSections() map[string]*Section {
return s.sects
}

//AllDatas return all key-value data
func (s *Section) AllDatas() map[string]string {
return s.data
}

func newSection(name string, depth int, parent *Section) *Section {
return &Section{
depth: depth,
Expand Down

0 comments on commit a4181a3

Please # to comment.