Skip to content

fix: allow env var to override non-zero struct values (#364)#365

Open
jyr94 wants to merge 1 commit intocaarlos0:mainfrom
jyr94:fix-env-var-override
Open

fix: allow env var to override non-zero struct values (#364)#365
jyr94 wants to merge 1 commit intocaarlos0:mainfrom
jyr94:fix-env-var-override

Conversation

@jyr94
Copy link

@jyr94 jyr94 commented Jul 15, 2025

Fixes #364

What this does

  • Ensures that environment variables override struct values,
    even when SetDefaultsForZeroValuesOnly is true.
  • Adjusts get(...) to return a flag indicating the value source.
  • Modifies setField to prioritize env vars.
  • Adds a test that reproduces the bug.

Why

The current logic prevents environment values from being applied
when the struct field is non-zero, which is not the intended behavior.

@kukymbr
Copy link

kukymbr commented Nov 7, 2025

@caarlos0 hi!
No pressure, but we really need this 🥹

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Values are not loaded from environment with SetDefaultsForZeroValuesOnly

2 participants

Comments