From ab7e9ada6f4515ec2781ac25d31be31938e992ce Mon Sep 17 00:00:00 2001 From: Roy Olav Purser Date: Fri, 18 Jun 2021 11:56:07 +0200 Subject: [PATCH] print errors after default values --- envconf.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/envconf.go b/envconf.go index 49f83dc..55a1e7d 100644 --- a/envconf.go +++ b/envconf.go @@ -128,7 +128,18 @@ func (c *Config) Status() (ok bool) { err := v.parsed.err if err != nil { ok = false - fmt.Fprintln(os.Stderr, err) + if !v.empty { + fmt.Fprintln(os.Stderr, err) + } + } + } + if !ok { + fmt.Fprintln(os.Stderr, "") + for _, v := range c.env { + err := v.parsed.err + if (err != nil) && v.empty { + fmt.Fprintln(os.Stderr, err) + } } } }