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
if you attempt to fill CustomFoo by passing a filename to UnmarshalString, it should read that file, then unmarshal into the CustomFoo struct. However, if you attempt to override the config with environment variables, the struct will attempt to be built twice, the first time with the value from config.yaml and the second time with the environment variable. if UnmarshalString returns an error it fails the config loading process. I'm attaching a runnable reproducer at the bottom, but IMO fig should wait until it has merged the different sources of config before it attempts to actually construct the final struct it will return to the caller.
expected result:
the Config struct is generated with Foo.Bar and Foo.Baz populated
actual result:
the foo.json file referenced in config.yaml is opened (and doesn't exist), rather than the foo_custom.json file referenced in the environment variables
error: 1 error(s) decoding:
* error decoding 'foo_config_file': open foo.json: no such file or directory
exit status 1
consider a config struct like
where
CustomFoo
:if you attempt to fill
CustomFoo
by passing a filename toUnmarshalString
, it should read that file, then unmarshal into theCustomFoo
struct. However, if you attempt to override the config with environment variables, the struct will attempt to be built twice, the first time with the value fromconfig.yaml
and the second time with the environment variable. ifUnmarshalString
returns an error it fails the config loading process. I'm attaching a runnable reproducer at the bottom, but IMOfig
should wait until it has merged the different sources of config before it attempts to actually construct the final struct it will return to the caller.expected result:
the Config struct is generated with Foo.Bar and Foo.Baz populated
actual result:
the
foo.json
file referenced inconfig.yaml
is opened (and doesn't exist), rather than thefoo_custom.json
file referenced in the environment variablesfull example
config.yaml:
foo.json: non-existent
custom_foo.json:
The text was updated successfully, but these errors were encountered: