Пример #1
0
func Load(filename string) (*Config, error) {
	data, err := ini.Load(filename)
	if err != nil {
		return nil, err
	}

	config := &Config{data: data}

	return config, nil
}
Пример #2
0
// NewWithOptions creates a GlobalConf from the provided
// Options. The caller is responsible for creating any
// referenced config files.
func NewWithOptions(opts *Options) (g *GlobalConf, err error) {
	Register("", flag.CommandLine)

	var dict ini.Dict
	if opts.Filename != "" {
		dict, err = ini.Load(opts.Filename)
		if err != nil {
			return nil, err
		}
	} else {
		dict = make(ini.Dict, 0)
	}

	return &GlobalConf{
		Filename:  opts.Filename,
		EnvPrefix: opts.EnvPrefix,
		dict:      &dict,
	}, nil
}