Exemple #1
0
func loadFile(filePath string) error {
	baseName := filepath.Base(filePath)
	extension := filepath.Ext(baseName)
	mainSectionName := baseName[:len(baseName)-len(extension)]

	sections, err := config.ParseFile(filePath, mainSectionName)
	if err != nil {
		return err
	}

	for section, options := range sections {
		if len(options) > 0 {
			locale := GetLocale(section)
			if locale == nil {
				locale = NewLocale(section)
			}
			for key, value := range options {
				locale.Add(key, value)
			}
			AddLocale(locale)
		}
	}

	return nil
}
Exemple #2
0
func loadRunnerConfigSettings() {
	if _, err := os.Stat(configPath()); err != nil {
		return
	}

	logger.Printf("Loading settings from %s", configPath())
	sections, err := config.ParseFile(configPath(), mainSettingsSection)
	if err != nil {
		return
	}

	for key, value := range sections[mainSettingsSection] {
		settings[key] = value
	}
}
Exemple #3
0
func loadConfigurationsFromFile(path, env string) {
	mainSectionName := "main"
	sections, err := config.ParseFile(path, mainSectionName)
	if err != nil {
		panic(err)
	}

	for section, options := range sections {
		if section == mainSectionName || section == env {
			for key, value := range options {
				SetVar(key, value)
			}
		}
	}
}