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

Skip processing on untagged fields that are structs with custom decoders #84

Closed
Jiraffe7 opened this issue Mar 7, 2023 · 1 comment
Closed

Comments

@Jiraffe7
Copy link

Jiraffe7 commented Mar 7, 2023

Custom decoders of structs are called even though the field is not annotated with env tag.
My use case is using go-envconfig to fill in values in a config struct that is already partially filled from other sources.

A minimal example results in an error Time.UnmarshalBinary: no data. This is unexpected behaviour as an error is returned and the original filled value is replaced by the zero value.

type Config struct {
	Time time.Time
}

I have seen #64 and #68 and I understand the need for backward compatibility, though they seem to apply to fields with env tags. Would it be possible to skip processing of untagged fields that are structs with custom decoders?

@sethvargo
Copy link
Owner

Hi there - I think #64 is exactly this, which leads to the path of #68 for maintaining backwards-compatibility.

Envconfig always allocates uninitialized fields, even without an env tag. This was an intentional design decision that differs from other env -> struct parsing libraries.

The only thing I think we could do would be to skip processing decoders with noinit, but I think even that would be a breaking API change unfortunately.

It'd be helpful to chime in with specific use cases on #69 to make sure we support them in 1.0+.

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