You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Found that even if my struct has the env-required or env-default set for the fields, if the environment variable was set but left empty, no error is rised, default value is not set either if used. Eg:
Lets say this var was set like this: export MY_VAR=""
If my struct were:
type MyVars struct {
MyVar string `env:"MY_VAR" env-required:"true"`
}
No error is raised at all, and i get and empty struct. If otherwise my struct had a default:
type MyVars struct {
MyVar string `env:"MY_VAR" env-default:"something"`
}
Id get an empty struct again rather than one with the default value.
Is this an expected behavior or could it be improved on?
The text was updated successfully, but these errors were encountered:
YoungOak
changed the title
Set but empty Environment Variables dont rise an error
Set but empty Environment Variables don't raise an error
Mar 17, 2023
Found that even if my struct has the
env-required
orenv-default
set for the fields, if the environment variable was set but left empty, no error is rised, default value is not set either if used. Eg:Lets say this var was set like this:
export MY_VAR=""
If my struct were:
No error is raised at all, and i get and empty struct. If otherwise my struct had a default:
Id get an empty struct again rather than one with the default value.
Is this an expected behavior or could it be improved on?
The text was updated successfully, but these errors were encountered: