Skip to content

Commit 1e2d9e1

Browse files
committedApr 25, 2024
docs: better explain UseFieldNameByDefault
refs #304
1 parent b436dff commit 1e2d9e1

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed
 

‎README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,8 @@ $ SECRET=/tmp/secret \
305305
If you don't want to set the `env` tag on every field, you can use the
306306
`UseFieldNameByDefault` option.
307307

308-
It will use the field name as environment variable name.
308+
It will use the field name to define the environment variable name.
309+
So, `Foo` becomes `FOO`, `FooBar` becomes `FOO_BAR`, and so on.
309310

310311
Here's an example:
311312

‎env.go

+2
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ type Options struct {
118118

119119
// UseFieldNameByDefault defines whether or not env should use the field
120120
// name by default if the `env` key is missing.
121+
// Note that the field name will be "converted" to conform with environment
122+
// variable names conventions.
121123
UseFieldNameByDefault bool
122124

123125
// Custom parse functions for different types.

0 commit comments

Comments
 (0)
Please sign in to comment.