Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to prepend prefix also to custom name taken from tag #29

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

albenik
Copy link
Contributor

@albenik albenik commented Oct 16, 2021

By default the struct like:

type Config struct {
	TestEnvFoo string `envconfig:"TEST_ENV_FOO"`
	TestEnvBar string
}

can be initialised from env: TEST_ENV_FOO, TEST_ENV_BAR if no prefix specified,
but from TEST_ENV_FOO, PFX_TEST_ENV_BAR, if PFX prefix is set.

I added ability to enable consistent prefix addition (see tests), with:

envconfig.InitWithOptions(&conf, envconfig.Options{
	Prefix:    "PFX",
	PrefixTag: true,
})

the struct described above will match PFX_TEST_ENV_FOO, PFX_TEST_ENV_BAR envs.

The default behaviour remain unchanged.

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