Skip to content

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