Configure environment variables using struct tags
masterYou can use struct tags to customize how fields are mapped to environment variables:
envconfig:"name": Specifies an alternate environment variable name (after the prefix).default:"value": Sets a default value if the environment variable is not present.required:"true": Returns an error during processing if the environment variable is missing (note: an empty string is considered present).ignored:"true": The field will not be processed even if a matching environment variable exists.split_words:"true": Enables automatic CamelCase to snake_case conversion. For example,AutoSplitVarbecomesMYAPP_AUTO_SPLIT_VARinstead ofMYAPP_AUTOSPLITVAR.
type Specification struct {
ManualOverride1 string `envconfig:"manual_override_1"`
DefaultVar string `default:"foobar"`
RequiredVar string `required:"true"`
IgnoredVar string `ignored:"true"`
AutoSplitVar string `split_words:"true"`
RequiredAndAutoSplitVar string `required:"true" split_words:"true"`
}