Decode reads the whole config from its input and stores it in the value pointed to by config.
(config *Config)
| 19 | // Decode reads the whole config from its input and stores it in the |
| 20 | // value pointed to by config. |
| 21 | func (d *Decoder) Decode(config *Config) error { |
| 22 | cb := func(s string, ss string, k string, v string, bv bool) error { |
| 23 | if ss == "" && k == "" { |
| 24 | config.Section(s) |
| 25 | return nil |
| 26 | } |
| 27 | |
| 28 | if ss != "" && k == "" { |
| 29 | config.Section(s).Subsection(ss) |
| 30 | return nil |
| 31 | } |
| 32 | |
| 33 | config.AddOption(s, ss, k, v) |
| 34 | return nil |
| 35 | } |
| 36 | return gcfg.ReadWithCallback(d, cb) |
| 37 | } |