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

Does this support parsing map[string]CustomStruct using the env tag? #108

Open
jasonlimantoro opened this issue Dec 9, 2022 · 1 comment

Comments

@jasonlimantoro
Copy link

jasonlimantoro commented Dec 9, 2022

For example, I have the following Config root

var RootConfig Root

type Root struct {
	Http map[string]HttpConfig `yaml:"http" env:"HTTP"`
}

type HttpConfig struct {
	Host      string `yaml:"host"`
	TimeoutMs int    `yaml:"timeout_ms"`
}

func Load(configPath string) {
	cleanenv.ReadConfig(configPath, &RootConfig)
}

I know I can provide the following to populate http key via the following yaml structure:

http:
  payment:
    host: "http://payment:4000"
    timeout_ms: 2000

But what about via environment variable? What would HTTP env var look like?

@jasonlimantoro jasonlimantoro changed the title Does this support parsing map[string]CustomStruct using the env tag? Does this support parsing map[string]CustomStruct using the env tag? Dec 9, 2022
@eloo
Copy link

eloo commented Feb 3, 2023

i'm also interested here as i have a similar usecase :)

would be really great if this would be possible

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

No branches or pull requests

2 participants