| 265 | } |
| 266 | |
| 267 | func initConfig(configFile string, ctType string, parser func([]byte, interface{}) error) (*Config, error) { |
| 268 | content, err := ioutil.ReadFile(configFile) |
| 269 | if err != nil { |
| 270 | return nil, errors.New("DotWeb:Config:initConfig current cType:" + ctType + " config file [" + configFile + "] cannot be parsed - " + err.Error()) |
| 271 | } |
| 272 | |
| 273 | var config *Config |
| 274 | err = parser(content, &config) |
| 275 | if err != nil { |
| 276 | return nil, errors.New("DotWeb:Config:initConfig current cType:" + ctType + " config file [" + configFile + "] cannot be parsed - " + err.Error()) |
| 277 | } |
| 278 | return config, nil |
| 279 | } |