LoadConfigFile reads a file and returns a new configuration representation. This representation can be queried with GetValue.
(fileName string, moreFiles ...string)
| 217 | // LoadConfigFile reads a file and returns a new configuration representation. |
| 218 | // This representation can be queried with GetValue. |
| 219 | func LoadConfigFile(fileName string, moreFiles ...string) (c *ConfigFile, err error) { |
| 220 | // Append files' name together. |
| 221 | fileNames := make([]string, 1, len(moreFiles)+1) |
| 222 | fileNames[0] = fileName |
| 223 | if len(moreFiles) > 0 { |
| 224 | fileNames = append(fileNames, moreFiles...) |
| 225 | } |
| 226 | |
| 227 | c = newConfigFile(fileNames) |
| 228 | |
| 229 | for _, name := range fileNames { |
| 230 | if err = c.loadFile(name); err != nil { |
| 231 | return nil, err |
| 232 | } |
| 233 | } |
| 234 | |
| 235 | return c, nil |
| 236 | } |
| 237 | |
| 238 | // Reload reloads configuration file in case it has changes. |
| 239 | func (c *ConfigFile) Reload() (err error) { |
searching dependent graphs…