From 1e2d9e135a1971a3b82f6874d26c6f4c012d2609 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Wed, 24 Apr 2024 23:13:27 -0300 Subject: [PATCH] docs: better explain UseFieldNameByDefault refs #304 --- README.md | 3 ++- env.go | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2caedeb..9a693a9 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/env.go b/env.go index 6d45ec6..d73ae09 100644 --- a/env.go +++ b/env.go @@ -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.