From 850e1df5322ef0db16e98f6b6600538f35bb1df2 Mon Sep 17 00:00:00 2001 From: ccoVeille <3875889+ccoVeille@users.noreply.github.com> Date: Thu, 5 Dec 2024 23:58:36 +0100 Subject: [PATCH] docs: fix code snippet about to handle a missing configuration file ConfigFileNotFoundError is a struct for 9 years ago (9fca1018) The wrong information was added in the documentation 5 years ago (5ae3a072) --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c2b2237..2744fbe 100644 --- a/README.md +++ b/README.md @@ -131,7 +131,8 @@ You can handle the specific case where no config file is found like this: ```go if err := viper.ReadInConfig(); err != nil { - if _, ok := err.(viper.ConfigFileNotFoundError); ok { + var errNotFound viper.ConfigFileNotFoundError + if errors.As(err, &errNotFound) { // Config file not found; ignore error if desired } else { // Config file was found but another error was produced