Closed YoungOak closed 6 months ago
It's an expected behavior. When reading variables from env, the program determines whether a value exists by determining whether the pointer is nil.
var envVal *string
if rawVal, ok := env.Lookup("foo"); ok {
envVal = &rawVal
}
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?