While reading configuration from yaml I noticed that if file not present I’ve got any errors in the foolowing example.
viper.SetConfigType("yaml")
file, _ := os.Open("example.yaml") //this file does not exist
defer file.Close()
err := viper.ReadConfig(file)
if err != nil {
if _, ok := err.(viper.ConfigFileNotFoundError); ok {
log.Fatal("configuration file not found")
} else {
log.Fatal(err)
}
}
None of the above errors happens. Is it not a ConfigFileNotFoundError if file not present?