Skip to content

Commit

Permalink
docs: better explain UseFieldNameByDefault
Browse files Browse the repository at this point in the history
refs #304
  • Loading branch information
caarlos0 committed Apr 25, 2024
1 parent b436dff commit 1e2d9e1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,8 @@ $ SECRET=/tmp/secret \
If you don't want to set the `env` tag on every field, you can use the
`UseFieldNameByDefault` option.

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

Here's an example:

Expand Down
2 changes: 2 additions & 0 deletions env.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ type Options struct {

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

// Custom parse functions for different types.
Expand Down

0 comments on commit 1e2d9e1

Please sign in to comment.