initConfig reads in config file and ENV variables if set.
()
| 70 | |
| 71 | // initConfig reads in config file and ENV variables if set. |
| 72 | func initConfig() { |
| 73 | if cfgFile != "" { |
| 74 | // Use config file from the flag. |
| 75 | viper.SetConfigFile(cfgFile) |
| 76 | } else { |
| 77 | // Find home directory. |
| 78 | home, err := homedir.Dir() |
| 79 | cobra.CheckErr(err) |
| 80 | |
| 81 | // Search config in home directory with name ".go-hexagonal" (without extension). |
| 82 | viper.AddConfigPath(home) |
| 83 | viper.SetConfigName(".go-hexagonal") |
| 84 | } |
| 85 | |
| 86 | viper.AutomaticEnv() // read in environment variables that match |
| 87 | |
| 88 | // If a config file is found, read it in. |
| 89 | if err := viper.ReadInConfig(); err == nil { |
| 90 | fmt.Fprintln(os.Stderr, "Using config file:", viper.ConfigFileUsed()) |
| 91 | } |
| 92 | } |
nothing calls this directly
no outgoing calls
no test coverage detected