env icon indicating copy to clipboard operation
env copied to clipboard

Support prefixes for environment variable lookups

Open hans-m-song opened this issue 1 year ago • 0 comments

Hello, I love how simple the interface of this library is, the only thing I find missing is the ability to include a prefix in the lookup. This would allow reusable structs with different environment "namespaces".

For example:

type test struct {
	Lorem string `env:"lorem"`
	Ipsum string `env:"ipsum"`
}

var (
	foo test
	bar test
)

func main() {
	env.Set(&foo, "FOO_")
	env.Set(&bar, "BAR_")
}

I will open pull request ready with a functional change, would just need some guidance on appropriate tests.

hans-m-song avatar Feb 06 '24 13:02 hans-m-song