Add default viper configuration

This commit is contained in:
Jip J. Dekker 2016-11-25 00:10:54 +01:00
parent 65306966af
commit f4556c43b6
2 changed files with 13 additions and 0 deletions

11
defaults.go Normal file
View File

@ -0,0 +1,11 @@
package main
import "github.com/spf13/viper"
func setDefaults() {
viper.SetDefault("Processes", 1)
viper.SetDefault("RawDir", "raw")
viper.SetDefault("Solvers", map[string]interface{}{})
}

View File

@ -26,6 +26,8 @@ func initConfig() {
viper.SetConfigFile(cfgFile)
}
setDefaults()
viper.SetConfigName("config") // name of config file (without extension)
viper.AddConfigPath("$HOME/.config/chronozinc") // add home directory as first search path
viper.AddConfigPath(".") // add current directory as an alternative