package cmd import ( "fmt" "log" "gitea.nehmer.net/torben/dyndns/service" "gitea.nehmer.net/torben/dyndns/webapi" "github.com/spf13/viper" ) func InitializeViper() { viper.SetConfigName("conf.yml") viper.SetConfigType("yaml") viper.AddConfigPath("/etc/dyndns") viper.AddConfigPath(".") if err := viper.ReadInConfig(); err != nil { if _, ok := err.(viper.ConfigFileNotFoundError); ok { log.Println("Could not find configfile, using defaults") } else { log.Fatalln(fmt.Sprintf("configuration is invalid: %s", err)) } } } func setAllConfigDefaults() { service.SetConfigDefaults() webapi.SetConfigDefaults() }