Invoking the the above with some environment set gives
$ SETTING_A=A SETTING_B=B go run env.go
envconfig says
--------------
setting_a:
setting_b:
setting_c:
Setting_a: A
Setting_b: B
Setting_c:
os.Getenv says
--------------
SETTING_A: A
SETTING_B: B
SETTING_C:
Two things that I expect to happen in the above situation are a) setting_a and setting_b fields are populated with the corresponding SETTING_A and SETTING_B strings from the environment and b) Process returns an error because SETTING_C is not present in the environment (either because setting_c or Setting_c fields mandate it to be).
The programme above shows that neither a) nor b) happen. I understand there are conventions related to uppercasing the first characters of struct fields in Go, but shouldn't an error be returned by Process because of a missing required key?
Hello,
This library looks handy, but doesn't behave as I expect. I've prepared a small code example that illustrates the behaviour that I am confused about.
Invoking the the above with some environment set gives
Two things that I expect to happen in the above situation are a)
setting_a
andsetting_b
fields are populated with the correspondingSETTING_A
andSETTING_B
strings from the environment and b)Process
returns an error becauseSETTING_C
is not present in the environment (either becausesetting_c
orSetting_c
fields mandate it to be).The programme above shows that neither a) nor b) happen. I understand there are conventions related to uppercasing the first characters of
struct
fields in Go, but shouldn't an error be returned byProcess
because of a missing required key?Cheers,
Ben