Make errcheck happy

This commit is contained in:
Anatoli Babenia 2020-02-22 07:10:26 +03:00
parent aea85a1f40
commit e15a2aa0d5

View File

@ -66,6 +66,8 @@ func initCli() {
// initConfig reads in config file and ENV variables if set.
func initConfig() {
var err error
viper.SetDefault("log.level", log.InfoLevel.String())
viper.SetDefault("log.path", "./dive.log")
viper.SetDefault("log.enabled", false)
@ -97,7 +99,11 @@ func initConfig() {
viper.SetDefault("container-engine", "docker")
viper.BindPFlag("source", rootCmd.PersistentFlags().Lookup("source"))
err = viper.BindPFlag("source", rootCmd.PersistentFlags().Lookup("source"))
if err != nil {
fmt.Println(err)
os.Exit(1)
}
viper.SetEnvPrefix("DIVE")
// replace all - with _ when looking for matching environment variables
@ -112,7 +118,7 @@ func initConfig() {
} else {
viper.SetConfigFile(cfgFile)
}
err := viper.ReadInConfig()
err = viper.ReadInConfig()
if err == nil {
fmt.Println("Using config file:", viper.ConfigFileUsed())
} else if cfgFile != "" {