func initConfig() {
	if cfgFile != "" {
		// Use config file from the flag.
		viper.SetConfigFile(cfgFile)
	} else {
		// Find home directory.
		home, err := homedir.Dir()
		if err != nil {
			fmt.Println(err)
			os.Exit(1)
		}

		// Search config in home directory with name ".banking" (without extension).
		viper.AddConfigPath(home)
		viper.SetConfigName(".banking")
	}

	viper.AutomaticEnv() // read in environment variables that match

	// If a config file is found, read it in.
	if err := viper.ReadInConfig(); err == nil {
		fmt.Println("Using config file:", viper.ConfigFileUsed())
	} else {
		// Find home directory.
		home, err := homedir.Dir()
		if err != nil {
			fmt.Println(err)
			os.Exit(1)
		}
		viper.WriteConfigAs(filepath.Join(home, ".banking.yaml"))
	}
}
// initConfig reads in config file and ENV variables if set.
initConfig reads in config file and ENV variables if set.
// initConfig reads in config file and ENV variables if set .
func initConfig() {
	if cfgFile != "" {
		viper.SetConfigFile(cfgFile)
	} else {
		home, err := homedir.Dir()
		if err != nil {
			fmt.Println(err)
			os.Exit(1)
		}
		viper.AddConfigPath(home)
		viper.SetConfigName(".banking")
	}
	viper.AutomaticEnv() 
	if err := viper.ReadInConfig(); err == nil {
		fmt.Println("Using config file:", viper.ConfigFileUsed())
	} else {
		home, err := homedir.Dir()
		if err != nil {
			fmt.Println(err)
			os.Exit(1)
		}
		viper.WriteConfigAs(filepath.Join(home, ".banking.yaml"))
	}
}
func initConfig ( ) { if cfgFile != " " { viper . SetConfigFile ( cfgFile ) } else { home , err := homedir . Dir ( ) if err != nil { fmt . Println ( err ) os . Exit ( 1 ) } viper . AddConfigPath ( home ) viper . SetConfigName ( " " ) } viper . AutomaticEnv ( ) if err := viper . ReadInConfig ( ) ; err == nil { fmt . Println ( " " , viper . ConfigFileUsed ( ) ) } else { home , err := homedir . Dir ( ) if err != nil { fmt . Println ( err ) os . Exit ( 1 ) } viper . WriteConfigAs ( filepath . Join ( home , " " ) ) } }
initConfig reads in config file and ENV variables if set.
initConfig reads in config file and ENV variables if set .
// Use config file from the flag. // Find home directory. // Search config in home directory with name ".banking" (without extension). // read in environment variables that match // If a config file is found, read it in. // Find home directory.