Exemple #1
0
func getConfMap(fileName string) (config.Config, error) {
	confFile := config.GetConfigFile(fileName)
	if confFile == nil {
		return nil, errors.New("Couldn't open config file.")
	}
	defer confFile.Close()

	var conf config.Config
	if confFile.Empty() {
		conf = config.Config{}
		conf["host"] = "localhost:8250"
		conf["bin"] = "mpcsd"
		confFile.Marshal(conf)
	} else {
		conf = confFile.Unmarshal()
	}
	return conf, nil
}
Exemple #2
0
func LoadConfig() {
	os.MkdirAll(*dataFolder, 0666)
	configFile := config.GetConfigFile(*dataFolder + "/" + *confName)
	if configFile != nil {
		var c config.Config
		defer configFile.Close()
		if configFile.Empty() {
			c = make(map[string]string)
			c["root"] = root
			c["port"] = strconv.Itoa(port)
			c["wsport"] = strconv.Itoa(wsport)
			c["loglevel"] = strconv.Itoa(loglvl)
			configFile.Marshal(c)

		} else {
			c = configFile.Unmarshal()
		}

		setVars(c)
	}
}