Skip to content

doc: getEnv wraps os.LookupEnv, not os.Getenv - #2182

Open
ump45nose wants to merge 1 commit into
spf13:masterfrom
ump45nose:doc-getenv-lookupenv
Open

ump45nose wants to merge 1 commit into
spf13:masterfrom
ump45nose:doc-getenv-lookupenv

Conversation

@ump45nose

Copy link
Copy Markdown

Overview:
Fix the getEnv doc comment: the method wraps os.LookupEnv, not os.Getenv, and additionally applies the AllowEmptyEnv rule.

What problem does it solve?:
The comment above getEnv says "a wrapper around os.Getenv", but the method returns (string, bool) obtained from os.LookupEnv (viper.go:421) and post-processes the result with ok && (v.allowEmptyEnv || val != "") (viper.go:423). os.Getenv cannot express either the presence check or the empty-value semantics, so the comment names the wrong function and hides the documented AllowEmptyEnv behavior.

Special notes for a reviewer:
Comment-only change, no behavior touched.

The method returns (string, bool) from os.LookupEnv and applies the
AllowEmptyEnv rule, which os.Getenv cannot express.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant