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

Support for nested struct environment mapping #30

Closed
malud opened this issue Sep 29, 2020 · 3 comments
Closed

Support for nested struct environment mapping #30

malud opened this issue Sep 29, 2020 · 3 comments
Labels
enhancement New feature or request good first issue Good for newcomers theme/config

Comments

@malud
Copy link
Collaborator

malud commented Sep 29, 2020

Currently we are able to map environment variables to configuration structs via tag.

An example:

type Config struct {
  DefaultPort int `env:"default_port"`
}

This gets internally prefixed with COUPER_ and uppercased. The value of COUPER_DEFAULT_PORT will be assigned to Config.DefaultPort.

The following example is not possible at this moment but should:

type Config struct {
  DefaultPort int `env:"default_port"`
  Timings Timings
}

Type Timings struct {
  Timeout time.Duration `env:"timeout"`
}

Env COUPER_TIMEOUT must be assigned to Config.Timings.Timeout.

Related files are config/env/env.go and runtime/http.go makes use of it.

@malud malud added enhancement New feature or request good first issue Good for newcomers hacktoberfest labels Sep 29, 2020
@mohammed786
Copy link

Hey @malud ,

Can I take this up as a hacktoberfest task?

@malud
Copy link
Collaborator Author

malud commented Sep 29, 2020

Sure. Go for it.

@malud
Copy link
Collaborator Author

malud commented Mar 15, 2021

Since we are calling our env mapping function for related structs directly this is not a requirement anymore.

@malud malud closed this as completed Mar 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers theme/config
Projects
None yet
Development

No branches or pull requests

3 participants